Using send_confirmation_email($user)

Using send_confirmation_email($user)

by Roger Mepham -
Number of replies: 1

Hello, hoping to get some assistance on using send_confirmation_email($user) to send a new user a confirmation email.

I am able to create users with the $userid = user_create_user($user); function from /user/lib.php with a confirmed value of 0 then trying to use the following code to send the newly created user a confirmation email:

require_once('../lib/moodlelib.php');
$emailsent = send_confirmation_email($user);

But no email is sent and $emailsent value is null

Any help would be very much appreciated, thanks

Roger

 

Average of ratings: -
In reply to Roger Mepham

Re: Using send_confirmation_email($user)

by Anne Krijger -

Hi Roger,

How do you get from the $userid returned by the user_create_user() to the $user object you use as parameter for send_confirmation_email()?

If you look at the send_confirmation_email function you'll see it ends up calling the email_to_user() function.

If you step through that code you can see all the checks that are done before an email is send out.

Is there an email server (smtp host) defined in the site settings btw?

 

Also: using a debugger to step through the Moodle code will help you a lot in understanding hoe Moodle works.

You also may want to enable debug level error reporting (see site admin - development) if it's not a production site.

Anne.