我有PHP代码发送邮件取决于消息和正文。但是邮件没有被发送而且没有错误
谁能告诉我这里的问题是什么
if ($userid == null) {
$smtpusername = "smtp". rand(1,20)."@nithin.com";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = SMTPAUTH; // enable SMTP authentication
$mail->Host = SMTPHOST; // sets the SMTP server
$mail->Port = SMTPPORT ; // set the SMTP port for the GMAIL server
$mail->SMTPSecure = SMTPSECURE; // Use ssl or tls to secure smtp calls
$mail->Username = $smtpusername; // SMTP account username
$mail->Password = SMTPPASSWORD; // SMTP account password
$mail->SetFrom('nithin@nithin.com','abc');
$mail->SMTPDebug = 1;
}
else {
//TODO: Fetch preferences, refer Taskera 1.0 version
}
$toarray = explode(',', $to);
$mail->Subject = $subject;
$mail->MsgHTML($htmlbody);
for($toiter = 0; $toiter < count($toarray); $toiter++)
$mail->AddAddress($toarray[$toiter], "");
$result = ($mail->Send());
if (!$result) {
$this->debug('MAILERROR', __FUNCTION__, 'Message sending failed. Error: ' . $mail->ErrorInfo);
return FAILURE;
}
错误
[Tue Jul 07 09:55:24 2015] [error] [client 192.168.1.232] PHP Catchable fatal error: Object of class PHPMailer could not be converted to string in /var/www/inc/base.inc on line 68, referer: https://www.nithin.com/
第68行
protected
function debug($function, $variable) {
if (is_array($variable))
$output = sprintf(" DEBUG: == %s() [%s]", $function, print_r($variable, true));
else
$output = sprintf(" DEBUG: == %s() (%s)", $function, $variable);
error_log($output);
}