[英]PHP mail function not sending email to Gmail account?
我正在使用一個WordPress插件在其中使用PHP郵件功能發送電子郵件,但是郵件功能存在問題。 它會將電子郵件發送到我的非Gmail帳戶,但不會將電子郵件發送到我的Gmail帳戶。 我正在使用以下代碼:
function send_mail()
{
global $wpdb;
$to = 'mymail@gmail.com';
$subject = 'Hello';
$name='my name';
$from="name@mydomain.com";
$message = "
<html>
<head>
<title>my title</title>
</head>
<body>
<div>
<tt> ".Hii How Are you."</tt>
</div>
</body>
</html>";
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: ".$name."<".$from.">\r\n";
mail($to, $subject, $message, $header);
}
我的代碼有問題嗎,還是郵件功能有問題? 如果有其他替代方法可以發送電子郵件,請給我鏈接。
檢查添加第五個變量是否對您有用...這是我發送電子郵件的代碼。
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
檢查垃圾郵件文件夾,它可能在那里。 它是服務器問題,它對我也發生了很多次。 Gmail由於某些原因阻止了某些服務器的郵件或發送到垃圾郵件。 要求您的服務器提供商檢查為什么郵件不發送到gmail收件箱。
使用下面的代碼示例,<>中的電子郵件地址,最后一個參數對我有用。
$headers = 'From: <test@test.com>' . "\r\n" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
這是PHP mail()函數中提供的答案, 它將不會發送到gmail,但會通過ARH3 發送到我的非gmail帳戶 ,這是我嘗試並測試過的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.