$userto in forums user email address

$userto in forums user email address

by smrithi puli -
Number of replies: 2

We are writing a code to generate .eml files. We see that the .eml files are created but when opened, the To field is mentioned as "none". I want to check as to where I can print the user's to field on the browser.

Please help

I am attaching a .eml file so that you can open and see what I am referring to here.

Average of ratings: -
In reply to smrithi puli

Re: $userto in forums user email address

by John White -
Smrithi,

$userto is an array filled in function forum_cron() in /mod/forum/lib.php
The array contains everything from table mdl_user for that one user (as well as other useful bits), hence $userto->email etc.

Function forum_cron calls function email_to_user(...) in /lib/moodlelib.php where array $userto is received as $user, so in here the email addresss is $user->email.

But within this function a call is made to &get_mailer() (also in moodlelib.php) to create a $mail object which itself contains a $mail->to array, which contains the email address at $mail->to[$key][0], and a translation for user's name to the appropriate character set at $mail->to[$key][1].
All of that is defined in /lib/phpmailer/class.phpmailer.php.

The function email_to_user(...) then calls $mail->send() obviously defined in the phpmailer class, which in turn has a VERY useful switch split between 3 types of 'mailer' - which you could so easily make 4 (though perhaps you have already???).
...and in which the to address is retrieved as $this->to[$i][0]

No wonder its easy to loose the address!!

Hope this is of help.

John





In reply to John White

Re: $userto in forums user email address

by smrithi puli -

Thanks John,

It really helped. But I figured it before you replied.

Thanks for taking the time out.