我有以下系统设置
我已使用以下内容配置了php.ini
文件:
smtp=smtp.gmail.com
smtp_port=25;
我的PHP代码是
<?php
mail('alagar.pandi@gmail.com','test subject','test body');
?>
我得到的错误是
Warning: mail() [function.mail]: SMTP server response:
530 5.7.0 Must issue a STARTTLS command first.
4sm389277yxd.16 in C:\wamp\www\limosbusesjets\test.php on line 5
有什么建议吗?
答案 0 :(得分:4)
我一直使用PHPMailer来满足我的所有邮件需求。 它已经内置支持GMail作为服务器(并且它是免费的)
我认为您的问题是您尝试使用PHP的邮件设置而不是PHPMailer 确保您有以下设置:
$mail = new PHPMailer(); //Setup the mailer
$mail->IsSMTP();
//$mail->SMTPDebug = 2;
$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
$mail->Username = $guser; //GMAIL username
$mail->Password = $gpwd; //GMAIL password
$mail->AddReplyTo($fromAddress,$fromName);
$mail->From = $guser;
$mail->FromName = "Your name";
$mail->Subject = $subject; //E-Mail subject
$mail->AltBody = $bodyAlt; //Text Body
$mail->WordWrap = 50; //set word wrap
$mail->Priority = $priority; //Mail priority
$mail->MsgHTML($ebody);
答案 1 :(得分:3)
Google上的邮件需要通过SSL运行。
主题上有很多arcticles,你可能会觉得这很有用:http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html