Comments (13)
Hello. I have tried to fetch new email messages using an instance of the Mailbox like instance.get_new_mail and didn't work. It works if I run:
python3 manage.py getmail
Is this a bug or am I doing something wrong?
Hi @LOH07,
What type of mailbox are you using?
from django-mailbox.
Hello. I have tried to fetch new email messages using an instance of the Mailbox like instance.get_new_mail and didn't work. It works if I run:
python3 manage.py getmail
Is this a bug or am I doing something wrong?Hi @LOH07, What type of mailbox are you using?
imap on localhost
It does work if I use
python3 manage.py getmail
but I want to fetch for a specific mailbox instance
It is very confusing because I don't get absolutely any error message
from django-mailbox.
Hello. I have tried to fetch new email messages using an instance of the Mailbox like instance.get_new_mail and didn't work. It works if I run:
python3 manage.py getmail
Is this a bug or am I doing something wrong?Hi @LOH07, What type of mailbox are you using?
imap on localhost It does work if I use
python3 manage.py getmail
but I want to fetch for a specific mailbox instance It is very confusing because I don't get absolutely any error message
It should work, here it is the code of manage.py getmail:
@staticmethod
def get_new_mail_all_mailboxes(args=None):
mailboxes = Mailbox.active_mailboxes.all()
if args:
mailboxes = mailboxes.filter(
name=' '.join(args)
)
for mailbox in mailboxes:
logger.info(
'Gathering messages for %s',
mailbox.name
)
messages = mailbox.get_new_mail()
for message in messages:
logger.info(
'Received %s (from %s)',
message.subject,
message.from_address
)
from django-mailbox.
Have you tried:
from django_mailbox.models import Mailbox,Message
mboxes = Mailbox.objects.all()
and then:
mboxes[0].get_new_mail();
It definitely doesn't work.
There already is an active mailbox in my database.
What frustrates me even more is the lack of any error message. Absolutely nada.
from django-mailbox.
I’m afraid we’d need more information to know how to help you. Could you elaborate on what isn’t working for you, or give us a traceback?
from django-mailbox.
I’m afraid we’d need more information to know how to help you. Could you elaborate on what isn’t working for you, or give us a traceback?
I have installed Dovecot and Postfix on my computer and they are running ok.
Then I installed django-mailbox via pip.
I created a Django app (just for testing purposes) and ran python3 manage.py migrate
in order to create the tables for django_postfix and then ran python3 manage.py getmail
. The database got populated with mailboxes and messages from Postfix. No problem so far but then whenever I go to the shell with python3 manage.py shell
and try to get new messages from Postfix with instance_of_Mailbox.get_new_mail;
nothing happens. The database doesn't get updated and there is no error message either.
Is it clear now?
from django-mailbox.
And you’re sure new mail messages were received between those two steps?
from django-mailbox.
And you’re sure new mail messages were received between those two steps?
python3 manage.py getmail
outside the django shell works. All messages are retrieved from Postfix. I can see in the database.
instance_of_Mailbox.get_new_mail;
doesn't work anywhere. Neither in django shell, nor in views.py
How can I collect more info to help you debug?
from django-mailbox.
I’m really going to need more information about what “not works” means, and can’t help but notice that my question above was not answered. Are you certain that there were new messages to retrieve?
from django-mailbox.
I’m really going to need more information about what “not works” means, and can’t help but notice that my question above was not answered. Are you certain that there were new messages to retrieve?
Yes, there are new messages to retrieve. This is the output in terminal when I run mail -u liviu
:
liviu@localhost:~$ mail -u liviu
"/var/mail/liviu": 2 messages 1 unread
1 Mail System Intern Sun Apr 30 15:41 13/520 DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
>U 2 liviu@localhost Sun Apr 30 17:08 16/433 Test msg
Held 2 messages in /var/mail/liviu
and this is the output to python3 manage.py getmail
:
liviu@localhost:~/DJANGO/EmailClient$ python3 manage.py getmail
INFO:django_mailbox.management.commands.getmail:Gathering messages for liviu
INFO:django_mailbox.management.commands.getmail:Received Test msg (from ['liviu@localhost'])
This works
from django-mailbox.
I'd be suspicious that when running getmail
vs. running the method directly that you're maybe interacting with different databases or something like that. Maybe, for example, when you're running getmail
from a shell, you're in a shell that isn't using the correct django configuration 🤷 They're invoking exactly the same code and I use this in production actively; so I can't imagine how this could be anything other than an environment problem.
For setting up a minimal pair of working/not-working to try this -- I suppose you could try:
- Opening bash or whatever.
- Send a test message to the relevant e-mail mailbox.
- Running
manage.py shell
:- Find the relevant
Mailbox
instance and run itsget_new_mail
method. - Verify that new mail was not received by running a query from this
manage.py shell
. CTRL+D
-ing to re-enter the exact same bash session.
- Find the relevant
- Running
manage.py getmail
from that exact same session.- Verify that new mail was received by runniong a query from a
manage.py shell
session created from this exact same session.
- Verify that new mail was received by runniong a query from a
from django-mailbox.
I'd be suspicious that when running
getmail
vs. running the method directly that you're maybe interacting with different databases or something like that. Maybe, for example, when you're runninggetmail
from a shell, you're in a shell that isn't using the correct django configuration shrug They're invoking exactly the same code and I use this in production actively; so I can't imagine how this could be anything other than an environment problem.For setting up a minimal pair of working/not-working to try this -- I suppose you could try:
Opening bash or whatever.
Send a test message to the relevant e-mail mailbox.
Running
manage.py shell
:
- Find the relevant
Mailbox
instance and run itsget_new_mail
method.- Verify that new mail was not received by running a query from this
manage.py shell
.CTRL+D
-ing to re-enter the exact same bash session.Running
manage.py getmail
from that exact same session.
- Verify that new mail was received by runniong a query from a
manage.py shell
session created from this exact same session.
That's exactly what I did.
But you are probably right that it must be an environment configuration issue.
Thanks for assistance.
from django-mailbox.
Closing since the issue does not seem relevant.
@LOH07 Feel free to re-open a new one if needed
from django-mailbox.
Related Issues (20)
- Missing migration? HOT 2
- ConnectionRefusedError: [Errno 111] Connection refused HOT 1
- documention not updating HOT 4
- get_new_mail from mailboxes inbox: where in mailbox are the loaded messages located? HOT 5
- ImportError: cannot import name ‘python_2_unicode_compatible’ from ‘django.utils.encoding’ (/opt/venv/lib/python3.8/site-packages/django/utils/encoding.py) HOT 12
- when will the new version of django_mailbox be released? HOT 2
- AttributeError: 'int' object has no attribute 'decode' HOT 1
- sort messages incoming date
- Error on fetch email from gmail using oauth2 but could be fetched using email and password
- Error when upgrading to Django 4.0 HOT 7
- Project status HOT 2
- Urgent: Error importing email HOT 4
- Microsoft Exchange Server/Outlook deprecating basic auth (IMAP and POP) HOT 2
- Is this package maintained?
- why is the logging level set to info for root logger?
- Release a new version to introduce support for python 3.9 HOT 1
- New Release With Office 365 API HOT 3
- Error migrating HOT 8
- when will the new code be released? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-mailbox.