I’m using Moodle where I allow user to register themselves, after which an email is sent to them. However, when user are registering, the email is not being sent and I’m getting the error:

Tried to send you an email but failed!

I have set the following SMTP details:

  • SMTP hosts: smtp.gmail.com
  • SMTP security: SSL
  • SMTP username: myusername@gmail.com
  • SMTP password: mypassword

How can I solve this error?

closed as off-topic by JakeGould, random Jan 17 '15 at 14:01

  • This question does not appear to be about computer software or computer hardware within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is an issue with your Moodle setup, which is not a desktop app– randomJan 17 '15 at 14:01
  • i'm not understanding by what you mean with "not a desktop app"– NoorJan 17 '15 at 15:23
  • What part of Moodle is a desktop app?– randomJan 17 '15 at 17:40

According to the official Moodle documentation, you need to make sure the correct port is set. Especially if you are using SSL:

Most SMTP hosts make use of the default port 25 to for listening emailtraffic. However, occasionally a non-default port is used. In suchcases, entering an SMTP host followed by a colon (i.e. :) and the portnumber should work. For example, if my SMTP host is myemailserver.comand it listens on port 587 or 465 (most common) instead of port 25 Iwould enter the SMTP host as myemailserver.com:587.

Looking at the official Google document entitled “Google Apps SMTP settings to send mail from a printer, scanner, or app” shows more info such as the SMTP port for Gmail being 465.

So knowing those two bits of information it seems to me that you should be changing the SMTP host from this:

smtp.gmail.com

To this:

smtp.gmail.com:465

And try again.

  • I put it as you said but still getting same problem, do you think this has got to do with PHP mail or any other configuraton on the server, because in my maillog, i'm seeing this: Jan 17 07:29:22 localhost postfix/sendmail[515]: warning: valid_hostname: invalid character 10(decimal): localhost.localdomain?server01 Jan 17 07:29:22 localhost postfix/sendmail[515]: fatal: unable to use my own hostname– NoorJan 17 '15 at 8:43
  • I honestly have no idea what your question us now. Sorry can no longer help you.– JakeGouldJan 17 '15 at 9:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.