Mail() - arriving at some addresses, never at others

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jerrygarciuh

    Mail() - arriving at some addresses, never at others

    Hi folks,

    HELP!!!!

    My habitual use of mail() is causing me some grief. I am having
    slightly different results depending on the server I use but the gist
    is that mail() is returning 1, and I can send mail to yahoo.com,
    gmail.com, and hotmail.com no problem. 100% success.

    Same script from some servers gets mail through to cox.net addresses,
    my ISP.

    However, my own domain, nolaflash.com is not receiving these mails at
    all, nor are several other domains on shared hosting servers.
    NolaFlash.com and Artifexdev.com for two examples.

    I have tried running the scripts on three different servers with the
    only difference that the Cox address works on one AND if I host the
    script on NolaFlash then the mail to NolaFlash addresses gets through.

    Here are four ways I have tried this:

    // NO HEADERS
    $to = 'someone@gmail. com';
    $subject = "Inquiry from some.com";
    $msg = 'whatever';
    $result = mail($to, $subject, $msg);

    // FULL HEADERS
    $to = 'someone@gmail. com';
    $subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
    $headers = "From: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Message-ID: <" . date("YdmHis") .
    ".TheSystem@".$ _SERVER['SERVER_NAME'].">" . "\r\n";
    $headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
    $result = mail($to, $subject, $msg, $headers);

    // FULL HEADERS PLUS -f FLAG to set the envelope sender address
    $to = 'someone@gmail. com';
    $subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
    $headers = "From: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
    $headers .= "Message-ID: <" . date("YdmHis") .
    ".TheSystem@".$ _SERVER['SERVER_NAME'].">" . "\r\n";
    $headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
    $result = mail($to, $subject, $msg, $headers,
    '-fwebmaster@mysi te.com');


    I have also played around with setting all the headers to good
    addresses at my site to see any bounces from the SMTP server.

    Any advice greatly appreciated!!!

    jg

  • Gordon Burditt

    #2
    Re: Mail() - arriving at some addresses, never at others

    >My habitual use of mail() is causing me some grief. I am having[color=blue]
    >slightly different results depending on the server I use but the gist
    >is that mail() is returning 1, and I can send mail to yahoo.com,
    >gmail.com, and hotmail.com no problem. 100% success.[/color]

    Directly putting values from $_POST[] into email headers without
    checking them for the absence of carriage return or linefeed
    characters WILL get you listed as a spammer because your page WILL
    be abused by spammers. (applies to your FULL HEADERS, FULL HEADERS
    PLUS, and I don't see the 4th way). If you see carriage returns
    or linefields in any fields to be put in headers, you should not
    send mail and tell the spammer to fuck off (but don't be so polite
    about it).

    You can expect that some servers will reject your message as SPAM
    because:
    - There is no From: line.
    - The address on the From: line is invalid.
    - The address on the From: line is not allowed to send mail from
    anyplace but specific servers (SPF) and the recipient server is
    enforcing it.
    - You aren't on their whitelist.
    - Some spammer abused a script on another site hosted by the same
    web provider as you did 6 years ago, and you have the same IP address.

    Gordon L. Burditt
    [color=blue]
    >Here are four ways I have tried this:
    >
    >// NO HEADERS
    >$to = 'someone@gmail. com';
    >$subject = "Inquiry from some.com";
    >$msg = 'whatever';
    >$result = mail($to, $subject, $msg);
    >
    >// FULL HEADERS
    >$to = 'someone@gmail. com';
    >$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
    >$headers = "From: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Message-ID: <" . date("YdmHis") .
    >".TheSystem@". $_SERVER['SERVER_NAME'].">" . "\r\n";
    >$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
    >$result = mail($to, $subject, $msg, $headers);
    >
    >// FULL HEADERS PLUS -f FLAG to set the envelope sender address
    >$to = 'someone@gmail. com';
    >$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
    >$headers = "From: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
    >$headers .= "Message-ID: <" . date("YdmHis") .
    >".TheSystem@". $_SERVER['SERVER_NAME'].">" . "\r\n";
    >$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
    >$result = mail($to, $subject, $msg, $headers,
    >'-fwebmaster@mysi te.com');
    >
    >
    >I have also played around with setting all the headers to good
    >addresses at my site to see any bounces from the SMTP server.[/color]

    Comment

    • jerrygarciuh

      #3
      Re: Mail() - arriving at some addresses, never at others

      Gordon,

      Thank you for the reply. Your advice is sound practice but in my
      opinion it doesn't address my difficulty.

      The mail which fails to arrive is being sent under controlled
      circumstances and with the exception of the No Headers version all
      attempts have included a From: header. And, for this controlled
      testing, I do know that there are no carriage returns in the values.

      The emails were generated on four seperate severs not owned by the same
      parent and hence IP blocks differed. The results however remained the
      same even when hard coded values were used in the headers. Each server
      could get it through to Gmail et al but none were getting it through to
      the vhosted accounts. If it was an IP based block it certainly is very
      broad.

      Anyway, thanks for considering my problem!

      jg

      Additionally the address which the
      Gordon Burditt wrote:[color=blue][color=green]
      > >My habitual use of mail() is causing me some grief. I am having
      > >slightly different results depending on the server I use but the gist
      > >is that mail() is returning 1, and I can send mail to yahoo.com,
      > >gmail.com, and hotmail.com no problem. 100% success.[/color]
      >
      > Directly putting values from $_POST[] into email headers without
      > checking them for the absence of carriage return or linefeed
      > characters WILL get you listed as a spammer because your page WILL
      > be abused by spammers. (applies to your FULL HEADERS, FULL HEADERS
      > PLUS, and I don't see the 4th way). If you see carriage returns
      > or linefields in any fields to be put in headers, you should not
      > send mail and tell the spammer to fuck off (but don't be so polite
      > about it).
      >
      > You can expect that some servers will reject your message as SPAM
      > because:
      > - There is no From: line.
      > - The address on the From: line is invalid.
      > - The address on the From: line is not allowed to send mail from
      > anyplace but specific servers (SPF) and the recipient server is
      > enforcing it.
      > - You aren't on their whitelist.
      > - Some spammer abused a script on another site hosted by the same
      > web provider as you did 6 years ago, and you have the same IP address.
      >
      > Gordon L. Burditt
      >[color=green]
      > >Here are four ways I have tried this:
      > >
      > >// NO HEADERS
      > >$to = 'someone@gmail. com';
      > >$subject = "Inquiry from some.com";
      > >$msg = 'whatever';
      > >$result = mail($to, $subject, $msg);
      > >
      > >// FULL HEADERS
      > >$to = 'someone@gmail. com';
      > >$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
      > >$headers = "From: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Message-ID: <" . date("YdmHis") .
      > >".TheSystem@". $_SERVER['SERVER_NAME'].">" . "\r\n";
      > >$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
      > >$result = mail($to, $subject, $msg, $headers);
      > >
      > >// FULL HEADERS PLUS -f FLAG to set the envelope sender address
      > >$to = 'someone@gmail. com';
      > >$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
      > >$headers = "From: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
      > >$headers .= "Message-ID: <" . date("YdmHis") .
      > >".TheSystem@". $_SERVER['SERVER_NAME'].">" . "\r\n";
      > >$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
      > >$result = mail($to, $subject, $msg, $headers,
      > >'-fwebmaster@mysi te.com');
      > >
      > >
      > >I have also played around with setting all the headers to good
      > >addresses at my site to see any bounces from the SMTP server.[/color][/color]

      Comment

      • Gordon Burditt

        #4
        Re: Mail() - arriving at some addresses, never at others

        >Thank you for the reply. Your advice is sound practice but in my[color=blue]
        >opinion it doesn't address my difficulty.
        >
        >The mail which fails to arrive is being sent under controlled
        >circumstance s and with the exception of the No Headers version all
        >attempts have included a From: header.[/color]

        If you send mail from PHP to the email address in the From: header,
        is it *ACTUALLY DELIVERED*? Yes, the left hand side really counts.

        If the domain in the From: line publishes an SPF record, is the
        web site you're running PHP on listed in it?

        Does the web site you're running PHP on have valid reverse DNS?
        Some mail servers won't accept mail from servers with no reverse DNS.

        Can you send email to a server you rent space on, have it fail,
        and get the ISP to tell you WHY it failed? Or look at the server
        logs yourself?

        [color=blue]
        >And, for this controlled
        >testing, I do know that there are no carriage returns in the values.[/color]

        Don't put it in production like that. Spammers will abuse it.
        But it shouldn't matter for your mail delivery problem.
        [color=blue]
        >The emails were generated on four seperate severs not owned by the same
        >parent and hence IP blocks differed. The results however remained the
        >same even when hard coded values were used in the headers. Each server
        >could get it through to Gmail et al but none were getting it through to
        >the vhosted accounts. If it was an IP based block it certainly is very
        >broad.[/color]

        Gordon L. Burditt

        Comment

        • jerrygarciuh

          #5
          Re: Mail() - arriving at some addresses, never at others

          Hi Gordon,

          Thanks for the continued help!

          AFAIK I have only used valid deliverable addresses as the FROM:. I
          have been using my own addresses. I will definitely bear in mind that
          it must be valid in future I had not been aware of that.

          As for your other questions, I will pursue answers to those as well,
          though I will probably get the admin to set up a mail account for the
          script to use and switch to using Perl's Mail:Sender module under AUTH.
          If problems persist then we can be pretty sure we have a blacklisting
          issue I think.

          Strange that in six years of using this method I have never been so
          stymied by it before.

          Anyway, I really do appreciate your time and advice!!

          Peace,

          jg

          Gordon Burditt wrote:[color=blue][color=green]
          > >Thank you for the reply. Your advice is sound practice but in my
          > >opinion it doesn't address my difficulty.
          > >
          > >The mail which fails to arrive is being sent under controlled
          > >circumstance s and with the exception of the No Headers version all
          > >attempts have included a From: header.[/color]
          >
          > If you send mail from PHP to the email address in the From: header,
          > is it *ACTUALLY DELIVERED*? Yes, the left hand side really counts.
          >
          > If the domain in the From: line publishes an SPF record, is the
          > web site you're running PHP on listed in it?
          >
          > Does the web site you're running PHP on have valid reverse DNS?
          > Some mail servers won't accept mail from servers with no reverse DNS.
          >
          > Can you send email to a server you rent space on, have it fail,
          > and get the ISP to tell you WHY it failed? Or look at the server
          > logs yourself?
          >
          >[color=green]
          > >And, for this controlled
          > >testing, I do know that there are no carriage returns in the values.[/color]
          >
          > Don't put it in production like that. Spammers will abuse it.
          > But it shouldn't matter for your mail delivery problem.
          >[color=green]
          > >The emails were generated on four seperate severs not owned by the same
          > >parent and hence IP blocks differed. The results however remained the
          > >same even when hard coded values were used in the headers. Each server
          > >could get it through to Gmail et al but none were getting it through to
          > >the vhosted accounts. If it was an IP based block it certainly is very
          > >broad.[/color]
          >
          > Gordon L. Burditt[/color]

          Comment

          • tony@tony.com

            #6
            Re: Mail() - arriving at some addresses, never at others

            [color=blue]
            > $subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";[/color]


            This is just a suggestion -

            Try sending your test emails with the suject "test"

            I have noticed some anti-virus-spam traps are now looking at the subject
            line for things like ".com" and rejecting them as if they were looking at
            executable files. (.com is a valid windows executable extension)

            Also be careful what you put in those variables.

            tony

            ps... should "Inquiry" be "Enquiry" ?


            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: Mail() - arriving at some addresses, never at others

              jerrygarciuh wrote:[color=blue]
              > Hi folks,
              >
              > HELP!!!!
              >
              > My habitual use of mail() is causing me some grief. I am having
              > slightly different results depending on the server I use but the gist
              > is that mail() is returning 1, and I can send mail to yahoo.com,
              > gmail.com, and hotmail.com no problem. 100% success.[/color]
              <snip>[color=blue]
              > I have also played around with setting all the headers to good
              > addresses at my site to see any bounces from the SMTP server.[/color]

              IIRC, there was/is some problem with mail() function and when the
              receiving server is too sensitive, it will throw syntax error and the
              e-mail will get bounced (eg. Yahoo). But, since you're saying that you
              could send to yahoo.com, it is better that you check for any bounced
              mails and reasons.

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

              Comment

              Working...