django-mailbox icon indicating copy to clipboard operation
django-mailbox copied to clipboard

Receiving Mail from Exim4

Open olivtree opened this issue 7 years ago • 8 comments
trafficstars

Hi, I am trying to configure exim4 to receive emails, as explained in the docs, but it is not working.

I tried running the command $python manage.py processincomingmessage but that does not work either.

I'm a little lost, because I do not see any errors in the log file. Can someone help me?

Thanks

olivtree avatar Dec 05 '17 12:12 olivtree

@olivtree , this command expects at input receive copies of the message. See http://django-mailbox.readthedocs.io/en/latest/topics/polling.html#receiving-mail-from-exim4 . You can use something like to test them: cat message.eml | python manage.py processincomingmessage

Exim4 must push copies of the message into the script. Alternatively, use the pull mode, e.g. via the IMAP mailbox.

ad-m avatar Dec 05 '17 13:12 ad-m

My goal is to receive emails automatically without a cron job.

I added router and transport configuration in my file: /etc/exim4/exim4.conf.template, but it is not working. So I tried to run the command set in transport (/path/to/your/environments/python /path/to/your/projects/manage.py processincomingmessage) on my command line to test.

olivtree avatar Dec 05 '17 14:12 olivtree

I'm afraid it's a little difficult to give much help for this sort of thing given that the problem is definitely going to be in how exim4 is wired-up to the management command, but have you tried checking the exim4 logs https://www.exim.org/exim-html-current/doc/html/spec_html/ch-log_files.html to see if you see any interesting errors?

Also -- it would be very helpful if you could explain "doesn't work" in more detail. Does that mean that you saw an error message -- if so, what was that error message?

coddingtonbear avatar Dec 05 '17 15:12 coddingtonbear

In docs, you can read

If you are utilizing one of the polling methods above, you will need to periodically poll the mailbox for messages using one of the below methods. If you are receiving mail directly from a mailserver via a pipe – using the processincomingmessage management command – you need not concern yourself with this section.

I do not want to run the "getemail" command whenever I receive an email in my mailbox. I understand from the docs that this can be done automatically using exim4 and the command processincomingmessage management. Am I understanding correctly?

olivtree avatar Dec 06 '17 10:12 olivtree

@olivtree , yes, you understand it correctly. However, instead you must correctly configure Exim4 to push messages to our command.

You still have not answered the previously asked questions.

ad-m avatar Dec 06 '17 10:12 ad-m

Thanks @ad-m!

I'm not getting any erros in exim4 log. In mainlog the following is shown: 2017-12-06 10:33:03 exim 4.82 daemon started: pid=9602, -q3m, listening for SMTP on port 25 (IPv6 and IPv4) 2017-12-06 10:33:03 Start queue run: pid=9604 2017-12-06 10:33:03 End queue run: pid=9604

I can not understand if the error is in the exim4 configuration or in the django_mailbox configuration in exim4 ... I'm lost, I hope you can help me.

olivtree avatar Dec 06 '17 10:12 olivtree

Please verify that the script is being executed in any way. Add, for example, to replace it with a temporary script that will write input to it to a temporary file. After receiving the message, the temporary file should be filled with the content. If it does not, it means that Exim4 is incorrectly configured.

ad-m avatar Dec 06 '17 10:12 ad-m

I do use this feature currently for consuming mail for a number of projects, so I'm fairly sure that it works. But, if you would like to validate assumptions, you should know that processincomingmessage expects (and what the exim4 setup process sets up exim4 to do) is to receive a well well-formed e-mail message via stdin. You can test that you are at least theoretically able to receive incoming messages by running --

python manage.py processincomingmessage

After a second, the terminal will hang there waiting for you to do something; you can then paste in the following text:

From: John Doe <[email protected]>
To: You <[email protected]>

This is what an e-mail message looks like when it's being sent across the internet.


After that, press <Ctrl+d> (which means "end of file" to unix processes), and you'll be brought back to your shell prompt. No error messages should be displayed.

Now, you can check in the database (or use the admin) to verify that your message was properly received.

coddingtonbear avatar Dec 06 '17 20:12 coddingtonbear

Look solved! Feel free to re open an issue if needed.

pfouque avatar Dec 18 '23 05:12 pfouque