嗨,我想在记录插入到数据库数据库表中后立即发送电子邮件,以下代码不起作用
if ($recs = $ti_form->get_data()) {
// Do something with the data, then redirect to a new page
$lastinsertid = $DB->insert_record('suggestions', $recs);
$toUser = '[email protected]';
$fromUser = 'ICAN';
$subject = 'New Suggestion Added';
$messageText = 'New Suggestion Added';
$sent = email_to_user($toUser, $fromUser, $subject, $messageText);
//mail($to, $subject, $message, $headers);
if($sent) {
print "Email successfully sent";
}else{
print "There was an error sending the mail";
}
redirect('suggestions.php');
}
上面的代码提供者错误消息。可能是什么原因?任何帮助,不胜感激。
谢谢
如果查看email_to_user()函数的phpdoc标头,则前2个参数应该是用户对象,而不是字符串。
* @param stdClass $user A {@link $USER} object
* @param stdClass $from A {@link $USER} object
所以对于用户
$touser = $DB->get_record('user', array('email' => '[email protected]');
对于发件人用户,您可以使用支持用户
$fromuser = core_user::get_support_user();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句