[英]Sending email through Gmail SMTP using PHP
我有以下系統設置
我已經使用以下內容配置了我的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
有什么建議?
我一直使用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);
通過Google發送的郵件需要通過SSL運行。
主題上有很多arcticles,你可能會覺得這很有用: http : //deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.