Uploaded users not receiving notification email

Uploaded users not receiving notification email

by Aysegul Cetin -
Number of replies: 31

Hi, we've just started using Moodle (3.2) and we're testing a way to manually upload students to a course and a seperate group, and let them know that an account has been created for them and they are enrolled in X course. I create the csv file with

username,password,firstname,lastname,email,course1,group1

I enter all the data for our dummy user and leave the password blank. I check "create password if needed" and upload, so that the user will receive an email notification asking him to create a permanent password. The user is created, enrolled in the correct course and seperate group, BUT no email notification is sent. I searched the forums but the solution I've found is this leaving the password blank option, and it doesn't seem to be working. What could be the problem?

Average of ratings: -
In reply to Aysegul Cetin

Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Does email work at all on your system? Are other things (e.g. forums) sending emails? Does the email account you used for your test *definitely* receive email from Moodle (don't say 'yes', try it)?

In reply to Howard Miller

Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Thank you. Yes, I tried logging in as the dummy user I uploaded, and clicked "forgot my password" and received a password reset email to the dummy user's email address. So email works on our system and the dummy user receives email from moodle to reset a forgotten password. Also, our students are getting course welcome emails from moodle when they enrol in a course.

In reply to Aysegul Cetin

Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Howard Miller

Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I must be doing something wrong. This is what my csv looks like:


And this is the screen:


In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I think your spreadsheet is set up wrong. It appears you have all the headings in A1 and all the data in A2. Each item needs to be in it's own cell of the spreadsheet so that when you save as a CSV file, it gets formatted correctly. I pretty much had the same type problem the first time I tried using CSV and making the change worked for me.


Average of ratings: Useful (1)
In reply to AL Rachels

Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -
Thank you so much for your reply. I wrote every item in its own cell in excel, and then saved it as a csv file.


When I try to upload it, moodle says "Not enough columns, please verify the delimiter setting".

I tried using notepad instead of excel and saved it as a csv file. This time moodle accepted the file, uploaded the user, said a password was generated by cron,
but no notification email was sent...  I'm installing LibreOffice now, I'll try creating the csv file with it.



In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You have a password column. You *must not* have a password column if you want the email sent. Moodle generates a temporary password for the user.

If you supply a password then it's your responsibility to notify them... no email is sent. 

PS. I always use LibreOffice to create the data. Excel likes to add in weird characters that break the CSV. 

Average of ratings: Useful (1)
In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Thank you for your reply. I installed LibreOffice and created the same file without the password column. I saved it as a csv file and uploaded.





Again, the user was created, enrolled in the right course and group, but no email was sent, although it says password generated in cron. I'm losing it!...

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you possibly can, I would check my mail server logs to see if there is any evidence of the email going through (or being rejected by) the mail server.

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I don't know where I can check the mail server logs, where can I see them? From my forum search, I understand that I must have access to the SMTP server. I don't have that. I can only access the moodle site as an admin.

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can also turn on mail debugging in Site administration > Development > Debugging.

This should give you a screen full of info if the Moodle is actually trying to send the mail. 

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Thank you for your reply. I went to Site Admin > Development > Debugging. Here I have to choose which debug messages to show. I chose "Show ALL reasonable php debugging messages". After this, which one should I check? "Display debug messages" and "Debug email sending"? And where does it display these messages?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Debug email sending is the important one here. It's worth changing the debugging level to 'Developer' *and* Display debug messages - just in case something else is going wrong that might be picked up. 

In the case of the user upload the mail is sent immediately (I think), so you should see the debug trace as soon as the file is uploaded. You won't miss it!

Average of ratings: Useful (1)
In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

OK, I set the debug messages: developer, I checked "display debug messages" and "debug mail sending". I uploaded the user through the same steps. No error message or such showed up on the user uploading or the result page. The user is created, enrolled in the course and the seperate group, it says "generated in cron" under password, and no email sent... Does this mean that it is not even attempting to send an email? It sends the email when I add a single user manually. I really don't understand why it does everything else right and just doesn't send the email when user is uploaded.

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I've looked at the code and I'm wrong about how this works. All that upload users does is to set a flag that a password is required. 

The password is generated and the mail sent by as task - core\task\send_new_user_passwords_task.  This seems to run every time the cron runs, but it does mean that your mail won't get sent until your next cron run. And... any debugging output will appear in the cron output.

You might want to check Site administration > Server > Scheduled tasks to see if/when that task last ran. 

Average of ratings: Useful (1)
In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

For every task in the Scheduled tasks, it says "Never" under Last run! Does this mean I have to schedule a task for Send new user passwords \core\task\send_new_user_passwords_task? And if I do that, will it have a negative effect on self-registering users (because students are currently self-registering without any problems)?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It doesn't sound like your cron is running. This means all sort of things won't be working properly. See Cron to get it set up.

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I read the Cron pages but I don't know if I can or should set up cron with my very limited knowledge of the system. If I schedule a task only for "Send new user passwords \core\task\send_new_user_passwords_task" through the Scheduled tasks page, will it run without needing to do anything else? And will it affect the current users? i.e. will they be prompted to change their passwords? Or does it work only for the users who have been given a temporary password by the site?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

No... you *need* to set up cron. Moodle won't work properly without it. 

Average of ratings: Useful (1)
In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Thank you for helping me. I have some more stupid-sounding questions to ask.

Our site opened 3 months ago and it was moved to a new server 2 weeks ago. The last run time for all the tasks on the Scheduled tasks page is "never". Is it possible that no one ever set up cron, and that the site has been running on pure luck all this time? (We have 760 students enrolled in a course and none of them reported any problems regarding signup, enrolment, gradebooks or activity completion etc.) Could cron be working but not visible to me when I look at Scheduled tasks page as the admin?

-If I am to set up cron now, is that something I can do through Site Admin > Server > Scheduled tasks? I don't have direct access to the server or the php files. Would scheduling tasks through that page mess something up?

In reply to Aysegul Cetin

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Here's what I found after a google search:

***

Your site may not have the cron set up at all. In this case you will see this message on the "Site administration" - "Notifications" page:

The cron.php maintenance script has not been run for at least 24 hours. *This is what I see when I go to Notifications.*

If this is the case, you should get this configured as soon as possible. Comprehensive instructions are available from https://docs.moodle.org/28/en/Cron.

If you are setting this up for the first time you may wish to add the following line to "config.php" (or just above the "?>" if it's present) for the first run:

$CFG->noemailever = true;

This will prevent any email being generated which, for an existing site that has had no cron running could prevent a lot of out-of-date and unwanted email. Don't forget to remove the line after you have got cron working."

***

From what I understand, users will get a lot of outdated emails if I set up cron now through the Scheduled tasks page without adding this line to that php file. The university's IT team does not know about this, either, I guess, or they would have set up cron when they moved the site to the new server and upgraded to Moodle 3.2.

How can I access that php file?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The config.php file is in the 'root' of your Moodle (code) installation. Do you have access to the Moodle files? You may have to take this up with your server admins I suppose. 

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

No, I don't have access to the Moodle files. Yes, I contacted the server admin and I do hope he will be able to help us with this... Thank you for trying to help me.

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

OK. Cron is set up now for all the tasks. I can see them on the Scheduled tasks page.

The next run for \core\task\send_new_user_passwords_task, it says ASAP.

The minute/hour/day/day of the week/month, all values are set to *.

Fail delay says 0.

However, the last time any task was run on the Scheduled tasks page is the same time and date (Sunday, 8 January 2017, 6:28 PM - we're in GMT +3), no matter when they were scheduled to run. I guess this was the first and the only time they were run.

The confirmation email for the dummy student was sent once, at exactly the same time and date (Sunday, 8 January 2017, 6:28 PM).

When I delete the user and upload him again, no confirmation email is sent. So it only worked once and then stopped working again. Any ideas..?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

How often is your cron set to run on the server (or however you set it up)?  In fact, how did you set it up?

On rare occasions, cron locks up or doesn't work properly. You can't possibly be that unlucky... wink

In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I didn't set it up. I explained this problem to the server admin and asked them to set up cron and they did. Everything on the Scheduled tasks page appears to be set to run at some time now (most of them are set to every minute). But the last time they ran is the same for all of them and they never ran again. Is it possible to set the cron to run only once but these tasks *appear* to be set to run every minute on the scheduled tasks page?

In reply to Aysegul Cetin

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I would get your server admin to check it. If you want a guess... they set it up wrongly (i.e. it doesn't work) but 'tested' the cron command line manually once. That's the one you see that worked. 

It'll be something like that.

Average of ratings: Useful (1)
In reply to Howard Miller

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Oh, I see... OK, I'll ask them again. If I ever get to see this cron monster run properly, I'll serve extra cans of catfood to all the cats in my street to thank you for all your help smile

In reply to Howard Miller

Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I've also tried manually adding a new dummy user instead of uploading user with a csv file. I added the user, checked "generate password and notify user" and it worked. The dummy user received an email including their username, temporary password and telling them that they have to change their password when they log in. So the site is able to generate passwords and notify users. It just doesn't work with uploaded users... sad

In reply to Aysegul Cetin

Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

Hello again. Previously, our Moodle site (3.2) sent emails when users self-registered via email or when they forgot their passwords; the only problem was that uploaded users didn't receive emails even when I omitted the password column in the csv file and checked "create password and notify via email". It turned out that cron was never set up. Now it is set up, and I can manually run it. I can see on the scheduled tasks page that "send_new_user_passwords" task was run after I manually run cron. However, Moodle stopped sending emails completely. Newly registered users or users who forgot their passwords do not receive emails. Do you have any ideas as to what might have gone wrong? Thank you...

In reply to Aysegul Cetin

Ynt: Re: Uploaded users not receiving notification email

by Aysegul Cetin -

I've just discovered that Moodle ONLY sends a confirmation or password email if the user's email address is in the same domain as the moodle site. (the site is moodle....xxx.edu.tr and only the users with an email address ...@xxx.edu.tr receive notification emails.) Could this be a coincidence? What kind of a problem does this point to?