我读过类似的帖子,但这个问题有所不同。问题是具有相同类的100%相同代码正在另一页上工作。但由于一些奇怪的原因,它不能在索引页面上工作。这是我得到的错误:
唯一的区别是工作文件位于root的子目录中,即/ xyz,但索引文件位于root中,而/是表单的操作指向子目录中的文件/ xyz / file .php所以我认为这不是一个问题。
PHP Catchable致命错误:PHPMailer类的对象无法转换为/home4/elliot/public_html/web.com/class.phpmailer.php on line 764
中的字符串
以下是PHP Mailer在764行显示的内容:
$address = trim($address);
这是什么工作代码:
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = "removed";
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "removed";
$mail->Password = "removed";
//Set who the message is to be sent from
$mail->setFrom('xx@xx.com', 'John Doe');
$mail->addReplyTo('xx@xx.com', 'John Doe');
//Set who the message is to be sent to
$mail->addAddress($email,$full);
$mail->Subject = 'Subject';
$mail->Body = $body;
$mail->IsHTML(true);
$mail->send();
以下是非工作代码:
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = "removed";
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "removed";
$mail->Password = "removed";
//Set who the message is to be sent from
$mail->setFrom('xx@xx.com', 'John Doe');
$mail->addReplyTo('xx@xx.com', 'John Doe');
//Set who the message is to be sent to
$mail->addAddress($email,$full);
$mail->Subject = 'Subject';
$mail->Body = $body;
$mail->IsHTML(true);
$mail->send();
答案 0 :(得分:8)
我明白了。这是一个愚蠢的错误。我正在为对象和电子邮件地址使用$ mail变量。