簡體   English   中英

PHP 郵件 function 通過 email 到垃圾郵件,除了 ZDE01C1D48DB6C321C637457113

[英]PHP mail function through email to junk except gmail

我正在嘗試在提交表單時使用 PHP mail() function 發送 email 。 不包括 GMAIL,電子郵件會變成垃圾郵件/垃圾郵件,我已經嘗試過 yahoo 和 outlook 作為其他 email 服務提供商。

我知道還有其他解決方案,例如 PHP 郵件程序或使用 SendGrid 或 Mailgun 等第三方服務發送 email,但我想知道是否有任何其他方法可以繞過其他 Z0C83F57CZ 提供程序中的垃圾郵件過濾器,例如 I am376A0BCZ 當前繞過Gmail。

郵件.php

<?php

function autoResponderEmail($name, $email) {
    
    $subject = "Thank you for submitting the form";
    $from = "email@example.com";
    $organization = "Organization Name Here";
    $message = "Thank you " . $name ." for contacting us. We will be in touch with you shortly." . "\n\n" . "Regards,\n" . $organization . " Team";
    
    $headers .= "Reply-To: ".$organization." <".$from.">\r\n"; 
    $headers .= "Return-Path: ".$organization." <".$from.">\r\n"; 
    $headers .= "From: ".$organization." <".$from.">\r\n";  
    $headers .= "Organization: ".$organization."\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
    $headers .= "X-Priority: 3\r\n";
    $headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;
    
    $sendMail = mail($email, $subject, $message, $headers);

    if ($sendMail) {
        header('Location: ./index.html');

    } else {
        alert('Failed to send email');
    }
    
}

if(isset($_POST['submit'])){
    $to = "email@example.com";
    $organization = "Organization Name Here";
    $full_name = $_POST['full_name'];
    $from = $_POST['email_address'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];
    
    
    $detail .= "Name: " . $full_name . "\r\n";
    $detail .= "Email: " . $from . "\r\n";
    $detail .= "Phone: " . $phone . "\r\n";
    $detail .= "Subject: New Contact Inquiry" . "\r\n";
    $detail .= "Organization: " . $organization . "\r\n";
    $detail .= "Message: " . $message . "\r\n";
    
    $headers .= "Reply-To: ".$organization." <".$to.">\r\n"; 
    $headers .= "Return-Path: ".$organization." <".$to.">\r\n"; 
    $headers .= 'Cc: waqas.jamal@sixlogs.com' . "\r\n";;
    $headers .= "From: ".$organization." <".$to.">\r\n";  
    $headers .= "Organization: ".$organization."\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
    $headers .= "X-Priority: 3\r\n";
    $headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;

    $sendMail = mail($to, $subject, $detail, $headers);

    if ($sendMail) {
        autoResponderEmail($full_name, $from);
    } else {
        alert('Failed to send email');
    }


};

?>

不,如果有辦法繞過垃圾郵件過濾器,它們就不是垃圾郵件過濾器。

查看已被放入垃圾郵件的已接收郵件的原始來源。 大多數 email 提供商會添加標題,解釋它如何以及為什么會成為垃圾郵件。

您在此代碼中做錯了許多事情,可能會將其標記為垃圾郵件:

您正在設置返回路徑 header。 這是違反 RFC 的,因為那是接收者的工作。 如果要設置信封發件人,請在mail()additional_params參數參數中使用-f選項。

您沒有在此處進行任何 DKIM 簽名。 可能是您的本地郵件服務器正在為您執行此操作,但如果您不是,這可能是一個原因。

在您的第二個示例中,您正在偽造發件人地址,這幾乎總是會將您的郵件標記為垃圾郵件。 如果您希望能夠回復提交者的地址,請使用您自己的(非偽造)地址作為發件人地址,並將提交者的地址添加為回復。

您的腳本容易受到 header 注入攻擊。

您沒有對您的消息正文進行任何處理,並且它包含用戶提供的內容,因此它很可能導致錯誤編碼的消息,這可能會導致漏洞,尤其是與可能導致可注入附件的 header 注入結合使用時。

這就是人們使用 PHPMailer 之類的庫來幫助您避免所有這些問題的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM