我想使用SMTP發送來自PHP的電子郵件,但每次我收到我的垃圾郵件中的電子郵件。我在谷歌搜索,並得到了一些解決方案,但我仍然收到垃圾郵件的電子郵件。你能幫我嗎?使用SMTP和電子郵件從PHP發送電子郵件轉到spam.What是最簡單的方式發送電子郵件到收件箱?
//$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '***'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption,'ssl' also accepted
$mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('[email protected]', 'admin'); //Set who the message is to be sent from
$mail->addReplyTo('[email protected]', 'First Last'); //Set an alternative reply-to address
$mail->addAddress($to, 'user'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Hello';
$mail->Body = "<html>
<head>
<title>HTML email</title>
</head>
<body>
<a href='/changepassword.php?user_id=" .$User_id1."'>Create your password here</a>
</body>
</html>";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
結帳:http://stackoverflow.com/questions/746809/prevent-sent-emails-treated-as-junk-mails-using-php-mail-function – Ajay
試圖找到全球的IP地址黑名單。 – nagiyevel
謝謝答覆Mr.Ajay。我也檢查過,但仍然收到垃圾郵件。 –