我最近尝试使用邮件系统,但它不像以前那样工作

时间:2016-09-15 12:49:39

标签: php phpmailer

我曾经成功构建了我的邮件系统,但当时我并不了解其内部发生了什么。

现在,我正在使用PHPMailer重新构建相同的系统,现在发生Gateway Timeout错误。请帮我修改我的代码。我所做的只是复制示例并输入我的帐户和密码。

$Mail = new PHPMailer;
$Mail->SMTPDebug = 2;
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port
$Mail->Username = 'myid@gmail.com'; // SMTP account username
$Mail->Password = 'mypassword'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'SUB';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'gatesplan@gmail.com';
$Mail->FromName = 'FROM NAME';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line

$Mail->AddAddress($email); // To:
$Mail->isHTML(TRUE);
$Mail->Body = "Hi";
$Mail->AltBody = "Hi";
$Mail->Send();
$Mail->SmtpClose();

0 个答案:

没有答案