email

email

by Jonathan Jones -
Number of replies: 10

Hello, I am hoping that someone here can shed a little light on a issue that I am having. I have read through the forums and have tried many suggestions to no avail. 

I have a new moodle installation (2.4.3) installed on a new dell server running Centos 6.3. 

Everything is running good with the exception of email. For some reason it is not sending out emails. Before you respond, let me just say. I have tried all the normal and easy stuff. Have configured it within moodle itself, using the messaging--email options, and yes all my settings are correct. I am able to telnet into the smtp server without any issues from the server itself. 

(We are using our own smtp server)

I have confirmed that the smtp info is in fact in the mysql database and have tried changing some of the info in a few of the php files but no luck yet. I am thinking that is where my problem is but I am not exactly certain which php file needs to be modified. 

This is the message I receive from the email debugging:

SMTP -> ERROR: Failed to connect to server:  (0)

Any insight into this issue would be greatly appreciative

Thanks

Average of ratings: -
In reply to Jonathan Jones

Re: email

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Does the machine run a SMTP server?

Is SELinux is active?

Try the standard CLI trick for SMTP:


$ telnet localhost 25 
Trying 127.0.0.1...
EHLO foo.bar
...
MAIL FROM: nobody@example.com
250 2.1.0 Ok
RCPT TO: you@your.domain
250 2.1.5 Ok
DATA
354 End data with .
Just a test
.

250 2.0.0 Ok: queued as 3DBB3C116A


And check the mailbox you@your.domain.

Also monitor:
$ tail -f /var/log/maillog

In reply to Visvanath Ratnaweera

Re: email

by Jonathan Jones -
No the moodle server does not run a smtp server, it is hosted on a separate machine. Yes SELinux is active, I have tried setting it to permissive mode but it did not help. I could disable it and see if it could help? As I stated I am able to telnet into the smtp server from the moodle server and everything seems to be ok that way, the problem only seems that moodle will not send emails when users create an account or when they are sent emails or post in forums.
In reply to Jonathan Jones

Re: email

by Ken Task -
Picture of Particularly helpful Moodlers

Changes to SELinux (setting to permissive) might require restart of the server.  That might be a factor.  Check server logs. But ... something to check first ... logs/maillog.

Moodle still needs an MTA (mail transfer agent) on the Moodle server itself.  On a CentOS 6.3 that's probably either postfix or exim (could be sendmail as well).  Don't set up the server to be a full fledged mail server ... just the ability to send is all that is needed.

Have webmin installed?  That will help determine and config.

Discovery: yum list postfix

Running? ps aux |grep postfix

http://ithelpblog.com/os/linux/redhat/centos-redhat/howto-install-postfix-mail-server-on-centos-6-3-or-redhat-6-3-rhel/

'spirit of sharing', Ken

 

In reply to Ken Task

Re: email

by Jonathan Jones -

didnt think about the need to restart the server after changing the SELinux permissions, u may be onto something there. yes webmin is installed, thought that was a prerequist, lol. postfix come already installed on centos, however not sure if it comes setup ready to send or not will have to check into that.

will test this out tomorrow and get back to ya, thanks.

In reply to Ken Task

Re: email

by Jonathan Jones -

Ok I changed SELinux to permissive and even completely disabled it and I still am receiving the same error:

SMTP -> ERROR: Failed to connect to server:  (0)

Postfix is installed and running.

Any other ideas?

In reply to Jonathan Jones

Re: email

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
You said:
>>> No the moodle server does not run a smtp server, it is hosted on a separate machine.

> I still am receiving the same error:
> SMTP -> ERROR: Failed to connect to server: (0)
> Postfix is installed and running.

Still the same procedure.
- Instead of "telnet localhost 25" this time "telnet MAILSERVER PORT".
- Once that works see to that the same values are entered in the Moodle mail configuration.
- Monitor (tail -f) the maillog, write a forum post, set "send now" and execure the cron.php.

> Any other ideas?

Wrong question. That is the Windows way. In Unix you !_debug_!

In reply to Jonathan Jones

Re: email

by Ken Task -
Picture of Particularly helpful Moodlers

Have you run the cron job and viewed it's output:

cd /moodle/admin/cli/

php cron.php [ENTER]

Did you check server logs for postfix?

Some postfix help:

postfix check                 # checks postfix configuration

postqueue -p                  # checks the queue

DNS must work when it comes to sending EMail.  Can the Moodle server lookup the smtp server by name?  Use dig to test:

dig smtpserver.somenet.net

IF dig fails, one might have to resort to adding an entry to the /etc/host file such as:

IPaddress fqdn.of.smtpserver hostname

example:

10.150.1.36 smtpserver.somenet.net smtpserver

NOTE: it is not unusal for an All Windows network NOT to use Internet DNS domain naming system internally.

Install nmap via yum: yum -y install nmap

Then scan the smtp server for port 25 opened to the Moodle server:

nmap -P0 -p 25 fqdn.smtpserver.somenet

Didn't you say you had webmin installed?  Webmin has 'Read Mail' which gets you into an inbox of a user on the system - ie, root.  Use Webmins ability to send mail from root account to a user on the STMP server.

It takes two to communicate ... on the SMTP server end ...

check logs, Moodle user being used allowed to relay, moodle server allowed to relay?

'spirit of sharing', Ken

In reply to Jonathan Jones

Re: email

by Jonathan Jones -

issue has been resolved, just needed to configure postfix to relay to my smtp server.

Thanks for the help

In reply to Jonathan Jones

Re: email

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
So there was a local SMTP server running after all?
In reply to Visvanath Ratnaweera

Re: email

by Jonathan Jones -

yes we run our own smtp server, i had to configure postfix one the moodle server to relay the email to our smtp server. Once i did that everythign started working like it was suppose to.