Hello,
I'm trying to write a simple script that to send an email. I am trying to use the email_to_user() built-in function but am failing so far. Here is the code I am using:
$user = 'name@this_address_will_never_change.com';
$from = $USER->email;
$subject = 'Subject test';
$messagetext = 'This is just a test, please disregard it';
email_to_user($user, $from, $subject, $messagetext);
Could anyone please let me know what I am doing wrong?
I don't think I need to require_once moodlelib.php as it seems to be called by default on all Moodle pages where config.php is required. Am I correct in thinking this?
Any help with this would be much appreciated.
Cheers,
Fred
$user has to be an object like:
$user = get_record('user', 'id', $id);
$from has the same requirement.
$user = get_record('user', 'id', $id);
$from has the same requirement.
Thanks a lot for your answer Daniele.
I have made the changes and it now works perfectly
Cheers,
Fred
I have made the changes and it now works perfectly
Cheers,
Fred