【发布时间】:2014-06-05 06:51:30
【问题描述】:
以下是我的代码,我正在使用谷歌应用程序进行业务。在以下代码中,我已将密码替换为 *。我正在使用 apache2。
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Port = 465; // SMTP Port
$mail->Username = "adminbot@mycompany.com"; // SMTP account username
$mail->Password = "*********"; // SMTP account password
$mail->SetFrom('adminbot@mycompany.com', 'John Doe'); // FROM
$mail->AddReplyTo('adminbot@mycompany.com', 'John Doe'); // Reply TO
$mail->AddAddress('ZTruse1955@mycompany.com', 'Jane Doe'); // recipient email
$mail->Subject = "First SMTP Message"; // email subject
$mail->Body = "Hi! \n\n This is my first e-mail sent through Google SMTP using PHPMailer.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
当我打开页面时,我得到空白,打开页面时没有收到任何邮件。 除了默认的膝上安装之外,我是否需要安装任何 php 库才能工作?
【问题讨论】:
-
表示有错误,否则可能进入if或else条件。检查您的错误日志
-
在哪里可以找到我的 php apache2 错误日志?
-
或将
<?php error_reporting(E_ALL); ?>放在页面顶部