简体   繁体   English

PHP邮件功能未从Gmail地址发送

[英]PHP Mail Function not sending from Gmail Addresses

I'm trying to get this contact form working and it doesn't seem to be able to send with headers saying it is from a gmail address I feel like yahoo addresses were also in the mix of ones that didn't work. 我正在尝试使此联系表单正常运行,但似乎无法发送带有标头的邮件,称它来自gmail地址,我觉得yahoo地址也存在问题。 Here is the code that seems like it would matter to this. 这是似乎对此很重要的代码。 If the host matters I am on Dreamhost. 如果主持人很重要,那么我在Dreamhost上。 Let me know please. 请让我知道。

    if(!is_array($contact_information_type))
{
    $contact_information_type = Array();
}

if($_POST){
    $contact_name = trim(stripslashes($_POST["contact_name"]));
    $contact_company = trim(stripslashes($_POST["contact_company"]));
    $contact_address1 = trim(stripslashes($_POST["contact_address1"]));
    $contact_address2 = trim(stripslashes($_POST["contact_address2"]));
    $contact_city = trim(stripslashes($_POST["contact_city"]));
    $contact_state = trim(stripslashes($_POST["contact_state"]));
    $contact_zip = trim(stripslashes($_POST["contact_zip"]));
    $contact_country = trim(stripslashes($_POST["contact_country"]));
    $contact_phone = trim(stripslashes($_POST["contact_phone"]));
    $contact_fax = trim(stripslashes($_POST["contact_fax"]));
    $contact_email = trim(stripslashes($_POST["contact_email"]));
    $contact_comments = trim(stripslashes($_POST["contact_comments"]));
if($contact_name == ""){ $errors_array[] = "Name is required."; }
if($contact_company == ""){ $errors_array[] = "Company name is required."; }
        if($contact_city == "") { $errors_array[] = "City is required."; }

if($contact_state == ""){ $errors_array[] = "State is required."; }




if($contact_country == "") { $errors_array[] = "Country is required.";}
elseif($contact_country == "United States" ) 
{if($contact_zip != "" && !preg_match("/(^\d{5}$)|(^\d{5}-\d{4}$)/", $contact_zip)){       $errors_array[] = "Incorrect Zip. (e.g. 60660 or 60660-1234)"; };}
elseif($contact_country == "Canada" ){if($contact_zip != "" && !preg_match("/^[ABCEGHJ-    NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$/i",     $contact_zip)){ $errors_array[] = "Incorrect Zip. (e.g. M4C 1B5 or M4C1B5)"; };}
                                                                                                                                                                                                                                else {;}






    if($contact_phone == ""){ $errors_array[] = "Phone is required."; }
    if($contact_phone != "" && !preg_match("/(^\d{3}-\d{3}-\d{4}$)|  (^\d{10}$)/", $contact_phone)){ $errors_array[] = "Incorrect Phone. (e.g. 123-123-1234)"; }
    if($contact_fax != "" && !preg_match("/(^\d{3}-\d{3}-\d{4}$)|(^\d{10}$)/",   $contact_fax)){ $errors_array[] = "Incorrect Fax. (e.g. 123-123-1234)"; }
    if($contact_email == ""){ $errors_array[] = "E-mail is required."; }
    if($contact_email != "" && !preg_match("/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+\.  [a-zA-Z0-9-.]+$/", $contact_email)){ $errors_array[] = "Incorrect E-mail. (e.g.   youremail@domain.com)"; }
if($contact_comments == ""){ $errors_array[] = "Comments are required."; }
    if(sizeof($errors_array) == 0){
        $contact_information_type = implode(", ",     $contact_information_type);

$email_message = <<<MESSAGE
The contact form on www.rotaryvalve.com has been filled out with the following information:


Name: ${contact_name}
Company: ${contact_company}
Address 1: ${contact_address1}
Address 2: ${contact_address2}
City: ${contact_city}
State: ${contact_state}
Zip: ${contact_zip}
Country: ${contact_country}
Phone: ${contact_phone}
Fax: ${contact_fax}
E-mail: ${contact_email}
Comments/Products of Interest: ${contact_comments}
MESSAGE;

        $email_adds = array("sales-team@wmwmeyer.com", "dan@danbaran.com");
        $email_from = $contact_email;
        $email_subject = "Customer Request/Comment";
        foreach($email_adds as $email_to){
            mail ($email_to, $email_subject, $email_message, "From: ".$email_from." <".$email_from.">");
        }

essentially if the contact_email filled out on the form(code not included sorry didn't think you'd need it but let me know if you do) is a gmail account it doesn't seem to send it please help me out on this one. 本质上,如果contact_email填写在表单上(不包括代码,对不起,您认为不需要,但请告诉我,如果您这样做)是一个gmail帐户,它似乎没有发送,请在此帐户上为我提供帮助。

Is the problem not being sent, or not being received. 问题是否未发送或未接收。 I'm pretty sure that the problem is not the email being sent, but what happens when it gets received by the receiver's email service. 我敢肯定,问题不在于发送的电子邮件,而是收件人的电子邮件服务收到邮件后会发生什么。 It may be classed as spam, because they can see it is not sent from the GMail mailservers. 它可能被归类为垃圾邮件,因为他们可以看到它不是从GMail邮件服务器发送的。

The email may be classed as spam by the receiving server or client, due to SPF records on the gmail.com domain that will most likely mark the emails as spam. 由于gmail.com域上的SPF记录很可能会将电子邮件标记为垃圾邮件,因此接收服务器或客户端可能会将电子邮件归类为垃圾邮件。

You would however be able to send the email with a 'Reply-To' header of the email entered in the contact form. 但是,您将能够发送带有在联系表单中输入的电子邮件的“回复”标题的电子邮件。 This would give the email a better chance of getting past spam filters, and if the recipient hits the "Reply" button in their client, the email will default to being sent to this address. 这将使电子邮件更有机会通过垃圾邮件过滤器,并且如果收件人在其客户端中单击“答复”按钮,则该电子邮件将默认发送到该地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM