Difficulty configuring to send mail

Difficulty configuring to send mail

by Anthony Borrow -
Number of replies: 10
Picture of Core developers Picture of Plugin developers Picture of Testers
It's been a long day of upgrading from Windows 2003 to Linux but I have my production site back up and running. Everything seems to be configured and running fine with the exception of email. I am running Debian and installed postfix. I have a user account called sender that I would like to use. My hostname -f is moodle.jesuitcp.org. I get confused with Postfix as to what the username is. I don't know whether to put the static ip, localhost, the full domain name, nothing? I am able to send fine through thunderbird using just the username; however, the moodle emails are not getting out. Any help would be appreciated as to where to look, commands to run, etc. I got this working on my test server but it is not connected to the outside and I just used sender@moodletest where the name of the hostname of the test server was moodletest. thanks again for any assistance. Peace
Average of ratings: -
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Maik Riecken -
Hi Anthony,

These are all no moodle specific question - you need to visit a mailserver forum. To receive mail  via thunderbird you'll need either a pop3 or an imap deamon running.

apt-get install qpopper

Will install a pop3 service fpr example. To receive mail from outside your server will need a valid mx-entry inside the DNS. Ask your provider or your administration for this.

regards,

Maik
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you need to configure postfix to send and receive mail for 'moodle.jesuitcp.org', you just need to specify 'myorigin', 'mydomain' and 'mydestionation' in main.cf.

Edit /etc/postfix/main.cf and edit your current 'myorigin' setting to read:

myorigin = moodle.jesuitcp.org

Next edit your 'mydomain' to read:

mydomain = jesuitcp.org

and finally edit your 'mydestination' to read:

mydestination = $myorigin, localhost, localhost.$mydomain

Reload your postfix service with:

/etc/init.d/postfix reload

and have a look at the end of /var/log/mail.log (where postfix sends its output in Debian) and check you don't have any messages saying there are syntax errors or similar things (just a 'configuration reloaded' message).

You can check your modified settings are all ok with:

postconf -n myorigin mydomain mydestination

That should do it. You can try fancier things later smile

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Difficulty configuring to send mail

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Thanks for the help with the Postfix side of things. I think Postfix is now configured OK. I think I mentioned that I was able to use thunderbird installed on the same machine to send an email using Postfix server as the SMTP but my Moodle generated emails were not getting out. Where can I look to get a better idea of what is happening? (the postfix logs? are there any moodle or php logs that might help?) With in Moodle, I'd like to know I am configuring things correctly. I would think that the hostname in Moodle would obviously be moodle.jesuitcp.org (but should I use localhost instead?), the username in linux is sender but should it be sender@localhost or sender@moodle.jesuitcp.org or sender@jesuitcp.org? The password I think I can handle. Peace - Anthony
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There are a couple of things you can do to debug this issue. First, you can have a look at the mail queue. It could be that postfix is accepting Moodle's mail, but not be able to send it (for whatever reason) and the mail is sitting on the mail queue. Login as root and issue this command:

/usr/sbin/postqueue -p

That will list all the mail waiting on the queue and the reason why it's waiting there. The first column lists the queue ID. If it has an '*' at the end, then postfix is trying to deliver the message right now. If not, the message is waiting for the next retry and you'll see a message telling you why it wasn't send the last time postfix tried to send it:

C68661FAA3*   13235 Wed Aug  2 12:00:04  rubies-bounces_at_listas.escomposlinux.org
                                     msalaza5_at_xtec.net

A69D31FADB    19661 Sun Jul 30 21:10:58  service_at_paypal.com
     (connect to bilo.escomposlinux.org[80.33.178.48]: Connection refused)
                                     bilo_at_bilo.escomposlinux.org

If your Moodle messages are not in the queue, then we need to have a look at the postfix logs. What I usually do is display the logs in real time while I try to send a message. Execute the following command:

tail -f /var/log/mail.log

that will output the las 10 lines of the postfix logs and wait for more content and display that content as soon as it arrives.

No go into Moodle and do something that sends a messages (like creating a new user using email authentication, for example) and see what gets logged in postfix. If you don't know what the log messages mean, you can paste them here and I'll have a look at them.

If you are running postfix and Moodle on the same server, leave all the 'smtp*' variables empty. That will use the local smtp server without any authentication, which will be fine.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Difficulty configuring to send mail

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Iñaki - Thanks for the Postfix tips. They have given me plenty to play with and I have made progress (I think). What I had considered the more difficult part of the puzzle is now working and the easier part is not. Our school uses an exchange server that sends all incoming mail to a spam checker. I mapped a transport for jesuitcp.org to smtp:ourspamcheckerserver.com. Anything sent to a jesuitcp.org address gets through; however, I cannot get mail to be sent to other addresses. They are not in the queue as I use webmin to help me out since my linux knowledge is limited. Looking at mail.log, nothing gets added when I use Moodle to send a message to a non-jesuitcp.org address; however, it pops right up when I send to a jesuitcp.org address. Hence, Moodle is able to connect to the smtp server. As far as for sending messages I am using the message feature that emails if a user is not online for a certain length of time. Any suggestions would be greatly appreciated?
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

FYI: the /etc/postfix/transport

jesuitcp.org smtp:ourspamserver.com

I suspect that I need to distinguish between local_transport, default_transport, etc so that it knows how to send non-jesuitcp.org email through smtp and the jesuitcp.org one's through postfix's (moodle.jesuitcp.org or localhost) smtp. I am just not sure exactly what the transport file should look like.

In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Iñaki - I am at a loss. I see the emails pass through mail.log if I send to a jesuitcp.org account through Moodle and Thunderbird. If I send to a non-jesuitcp.org account via Thunderbird I can see it pass through the mail.log; however, Moodle does not show up in the mail.log. I'm confused as to what could cause Moodle not to send to domains other than jesuitcp.org? The answer, the email account for the user I was sending to was disabled so Moodle was not attempting to send email even though the email address for the messaging system was different than for the main moodle system. Once I enable the user's email address it began passing throught the Postfix mail.log. Thanks for your help in pointing me towards the tools I needed to troubleshoot this and get it working. 
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> Our school uses an exchange server that

One wants to start the life anew and finds out one cannot escape from the old sh**. sad

If this Exchange adheres to common courtsey, like all the mail servers, it should work in a "distributed" fashion.

Putting it another way, if a mail server tries to send a mail to aguy@somedomain, the server checks the MX record of DNS, finds out the receiving server and delivers the message.

So your server must be able to send mail to _any_ domain, including your own. It is the duty of the mail server of your institution to do whatever they wish with your message.
In reply to Anthony Borrow

Re: Difficulty configuring to send mail

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Anthony

I wonder whether you are over-caring ;-(

In a default setup you leave all the fields (smtphosts, smtpuser, smtppass) empty. Then Moodle will try to deliver the mails it generates to the standard port, port 25, of the same machine.

Obviously a mail server (MTA in unix jargon) should be running in the server and listening to this port. In your case postfix. To avoid abuse it should be configured to accept only "internal" mail, ie. mail generated from the machine.

So Moodle has a easy life of launching its mail to the net (via local postfix).

So much theory. Two practical tips:

# tail -f /var/log/mail.log
or
# tail -f /var/log/maillog

will show you what your mailserver is doing.
(# means that you are root, don't type the hash!)

Once you change any configuration parameter of your mail server,
/etc/postfix/main.cf for example, you have to restart it. Depending on the distribution it will be something like

# /etc/init.d/rc3.d/postfix restart

In reply to Visvanath Ratnaweera

Re: Difficulty configuring to send mail

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Thanks for the suggestions - I was able to get it working. I know that normally you would just have it use localhost but I wanted to be 'over caring' and have the authentication to avoid any possibility or accusations that it was being used to send spam.