Could not send email !

Could not send email !

by peterpan lizeyu -
Number of replies: 8

I am using LDAP server,and i have connected to the LDAP server successfully,but when student login,they need to fill in  an email address, and when i press the "update profile" button, moodle told me "Could not send email !".I have a few screenshots. How can i solve this error? Thanks




Average of ratings: -
In reply to peterpan lizeyu

Re: Could not send email !

by Ken Task -
Picture of Particularly helpful Moodlers

Moodle expects the EMail address to be supplied by LDAP.   Look at the configuration of LDAP and especially the mapping of the email address in moodle to the object in LDAP that contains a users EMail address.  If moodle is able to acquire that object, students will not be prompted to fill in the email address and no notification email need be sent.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

回复: Re: Could not send email !

by peterpan lizeyu -

Thank you for your reply. But our school's LDAP SERVER don't have a 'mail' column, so I can't get the email address yet. Should I set up a smtp server from Site administration->server->Email ? Or there is another way? And I wonder why my

 Site administration->Plugins->message outputs->manage message outputs doesn't contain a Email "Settings".


thank you !

In reply to peterpan lizeyu

Re: 回复: Re: Could not send email !

by Ken Task -
Picture of Particularly helpful Moodlers

See:
https://docs.moodle.org/32/en/Upload_users

when you create the cvs file you could use LDAP in an authentication column
and 'false' email addresses for students  .... like bjones@example.com.

That will get users in ... however, if you allow students to change Email addresses
Moodle will attempt to send a confirmation message to the user ... account change is in limbo until confirmed.   And since  the email addresses are not real even if you get the SMTP setup working again, that will cause some issues.     Besides, right now one cannot get the Moodle
send mail - busted SMTP setup ... well, think you can see the situation cascades issues.

So if LDAP is to be the future of authentication for your Moodle, I'd advise taking your time and doing it right ....  getting LDAP populated with Email addresses now rather than trying to do something quick or you might have to revisit the whole situation again in the near future.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

回复: Re: 回复: Re: Could not send email !

by peterpan lizeyu -
Thank you Ken!  I have solved the problem by adding a "false" email address.  In China, universities usually don't set the email address as a 'required' column, so even in our school's main database we don't have a specific email address of students.  I read the moodle documentation,and I found that by default,moodle will send email with php method. Does it means I don't have to do any configuration to send a email? Or I have to do something to enable my moodlesite to send a email? 

Thank you very much!

By the way,My moodlesite's ip address is a local area network,If a want to send a email,I need to apply our school's network administrator to enable my ip's port25?

Much appreciate!

In reply to peterpan lizeyu

Re: 回复: Re: 回复: Re: Could not send email !

by Ken Task -
Picture of Particularly helpful Moodlers

If no SMTP server is entered into Moodle config, it will try to send mail via it's built-in PHPMailer. But if students have false email addresses whatever mail any portion of Moodle that attempts to send mail will fail - 'false' email addresses.   Take, for example, the 'Announcements' forum that could be present on the front page of a Moodle.   IF all students are forced subscribed to the forum, any posting there will mean Moodle's cron job, when run, will attempt to send an email which cannot be delivered.

IF students do change their profile and put in a true EMail address, mail to them may/may not be delivered ... Moodle will try to send, but receiving mail server might see the mail as spam or not authorized as a sending mail server from your network and the mail will be blocked by the receiving mail server ... even if network folks open port 25 to your server.

Does your moodle server have a fully qualified domain name (FQDN) ... like moodle.someuniv.net?

Having FQDN does help but very little when it comes to outbound mail successfully reaching students inboxes.

Opening port 25 (the smtp port) should not be necessary to send mail - only to receive mail.   Only your Network administrative staff would know the particulars about your private network so questions like getting mail delievered to all students at addresses outside your private Network should be asked of them.

Best of luck1

'spirit of sharing', Ken



In reply to Ken Task

Re: Could not send email !

by Maddy N -

Hello Sir,

I have the exact same issue, email could not be sent error once the LDAP authentication is successfully set and user logs in. After login he's asked to fill First name, Surname and email address and later it tries to send email to the given email id and gives "couldn't send email" error. And this error occurs even if I give a valid email address. Right now it doesn't have a FQDN.

You said "Look at the configuration of LDAP and especially the mapping of the email address in moodle to the object in LDAP that contains a users EMail address." Does that mean I need to fill Data Mapping fields (firstname, surname and email adress) in LDAP server authentication settings under site administration, with database fields in LDAP server?

In reply to Maddy N

Re: Could not send email !

by Ken Task -
Picture of Particularly helpful Moodlers

Yes, do need to map between LDAP objects and Moodle DB fields in mdl_user.

Please see:

https://docs.moodle.org/33/en/LDAP_authentication

If, once get things mapped, user can authenticate via LDAP and after logging onto the Moodle they are thrown into their profile, that's a sign that some required field for Moodle accounts was not acquired from LDAP.

If you plan to use the instance in production, might be best to acquire a FQDN for the Moodle server before you begin development of courses as Moodle does not use 'relative addressing' but, rather, uses the wwwroot variable in config.php of the installation and builds all internal urls with that value ... is, http://site/.

Also, if not using SMTP server, it is possible that the receiving mail server will not accept mail from your Moodle server as the Moodle server doesn't have DNS records receiving mail servers might check for blocking spam/phishing.

No, you do not want to turn your Moodle server into a full blown mail server.   Use SMTP.

See references on using STMP:

https://www.google.com/search?q=setting+up+smtp+moodle

'spirit of sharing', Ken