php sendmail 慢,通过PHPMailer发送邮件很慢

当我使用phpmailer通过Gmail发送邮件时,电子邮件需要很长时间才能发送,有时也不会发送。我使用XAMPP作为本地主机。通过PHPMailer发送邮件很慢

这里是我的代码:

if($_POST['submit']{

/*MAIL PART BEGINS*/

//error_reporting(E_ALL);

error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('class.phpmailer.php');

//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$body = "Your Password has been generated.

$body .="New Password = '$password'

$body .="Please Login with your Employee ID and this password and you can change the password at any time.";

//$body .="Amount Requested = '$amount'

//$body .="Amount Sanctioned = '$amount_sanctioned'

$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP

$mail->Host = "stmp.gmail.com"; // SMTP server

$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)

// 1 = errors and messages

// 2 = messages only

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl"; // sets the prefix to the servier

$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server

$mail->Port = 465; // set the SMTP port for the GMAIL server

$mail->Username = "[email protected]"; // GMAIL username

$mail->Password = "******"; // GMAIL password

$mail->SetFrom('[email protected]', 'First Last');

$mail->AddReplyTo("[email protected]","First Last");

$mail->Subject = "Change Password";

//$mail->AltBody = "Hello...!!!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "$email";

//$address1 = "[email protected]@hotmail.com";

//$address2 = "[email protected]@rediffmail.com";

//$address3 = "[email protected]@iicb.res.in";

$mail->AddAddress($address, "First Last");

//$mail->AddAddress($address1, "First Last");

//$mail->AddAddress($address2, "First Last");

//$mail->AddAddress($address3, "First Last");

//$mail->AddAttachment("images/phpmailer.gif"); // attachment

//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {

echo "Mailer Error: " . $mail->ErrorInfo;

} else {

echo "Message sent!";

}

//MAIL PART ENDS*/

}

2012-01-11

aki2all

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值