試した訳ではありませんが,多分,以下の箇所では無いでしょうか.
blocks/quickmail/email.phpの140行目あたり,
// run through each user id and send a copy of the email to him/her
// not sending 1 email with CC to all user ids because emails were required to be kept private
foreach ($form->mailto as $userid) {
if (!$courseusers[$userid]->emailstop) {
$mailresult = email_to_user($courseusers[$userid], $USER, $form->subject, $form->plaintxt, $form->html, $attachment, $attachname);
// checking for errors, if there is an error, store the name
この赤い行のところでメールを一人ずつ送信しているようです.第二引数の$USER(ログインユーザの情報)がFromになっているのでしょう.ここを直接書き換えるだけではダメだと思います.たとえば$USERをget_admin()に変更すれば管理者のメールアドレスになると思います.noreplyは...何か手があるのかも知れませんが,現段階では不明です.
少々,乱暴なやり方ですが,
// run through each user id and send a copy of the email to him/her
// not sending 1 email with CC to all user ids because emails were required to be kept private
// (ここから追加)
$noreplyuser = get_admin();
$noreplyuser->email = 'noreply@mysite.com';
$noreplyuser->firstname = '管理者';
// (ここまで追加)
$noreplyuser->lastname = 'サイト';
foreach ($form->mailto as $userid) {
if (!$courseusers[$userid]->emailstop) {
// $mailresult = email_to_user($courseusers[$userid], $USER, $form->subject, $form->plaintxt, $form->html, $attachment, $attachname);
$mailresult = email_to_user($courseusers[$userid], $noreplyuser, $form->subject, $form->plaintxt, $form->html, $attachment, $attachname);
// checking for errors, if there is an error, store the name
if (!$mailresult || (string) $mailresult == 'emailstop') {
このようにユーザ情報を偽装する(サイト管理者の情報をコピーして,氏名とEmailアドレスを書き換え)ことで実現可能であることを確認しました.
もちろん,これでは全てのQuickMailブロックからのメールの送信元がnoreply@mysite.comになってしまうので,何らかの工夫が必要です.たとえば特定のユーザIDからのメールの送信の時のみ,上部のユーザ情報の複製を行う,など.
ただ、みなさんの解答が待ち切れずに、えいや~で試しました。
/lib/phpmailer/class.phpmailer.php(801行目あたり)です。
// $result . = $this -> AddrAppend("From", "$from");
$result . = $this -> AddrAppend("noreply", "サイト");
// sendmail and mail() extract Bcc from the header before sending
if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
$result .= $this->AddrAppend("Bcc", $this->bcc);
とりあえず、動きました。
ただ、私は全くの無知なので、先生の方法で試してみます。
別件で,lib/moodlelib.php の function email_to_user()を調べていて,
if (is_string($from)) { // So we can pass whatever we want if there is need
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from;
} else if ($usetrueaddress and $from->maildisplay) {
$mail->From = stripslashes($from->email);
$mail->FromName = fullname($from);
} else {
$mail->From = $CFG->noreplyaddress;
$mail->FromName = fullname($from);
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress,get_string('noreplyname'));
}
}
このようなコードを見付けました.確かに,ダイジェストメールは個人のEmailアドレスではなく,サイトのドメインを持つ存在しないEmailアドレスです.たとえば当方のサイトですと,moodle@mech.suzuka-ct.ac.jp.
ダイジェストメールの送信は,mod/forum/lib.phpのfunction forum_cron()の後の方,
if (!$mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml,
'', '', $CFG->forum_replytouser)) {
こうですね.第二引数がメールの送信者の情報で,本来はオブジェクトを渡すべきなのですが,ここではサイトのショートネーム(当方ですと,mechMoodle)を渡しています.前に参照した箇所では第1のif文の条件に合致しますね.これで$CFG->noreplyaddressが電子メールアドレスで,名前がmechMoodleになるという仕組みのようです.これを利用しては如何でしょう.