我一直使用
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 = ""; //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);
如果觉得《php gmail smtp 使用PHP通过Gmail SMTP发送电子邮件》对你有帮助,请点赞、收藏,并留下你的观点哦!