Hi,

I have php form mail which sends mails out without any problems. I have a from address configured as "conference@toastmasters.org.pt" and when I receive mails at my gmail/hotmail or any other accounts, the FROM address is always conference@toastmasters.org.pt

However, the mails sent to my Yahoo account from this form always comes with a FROM address "toastmasters@yahoo.com"!!!

I checked with 3 different yahoo mail accounts and the behaviour is the same! There is no such mail account and I dont have it anywhere in my code.

Any suggestions on why this is happening? and how to rectify this?

Tx,
sg

    Have you inspected the complete mail headers? Also, how does your php form send the mail? Is it using the [man]mail[/man] function? Is it using PEAR::Mail or some other class that connects to an SMTP server? Are you using a yahoo account to send out your mail?

      Hi,

      The headers seem to be fine. I am using the mail() function and my code reads as follows:

      $headers = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      $headers .= "From: conference@toastmasters.org.pt \r\n" ."X-Mailer: php \n";
      $headers .= "Cc: conference@toastmasters.org.pt \n";

      if (mail($to, $subject, $body, $headers)) .....

      I am not using any yahoo account to send mails and have only one FROM address as seen above..

      I just happened to notice another thing. The mails I received in CC all have a FROM address - Toastmasters@.SYNTAX-ERROR.

      Is there anything wrong with my code?

        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "From: conference@toastmasters.org.pt\r\n"
        $headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
        $headers .= "Cc: conference@toastmasters.org.pt";
        

          Ok, I have figured it out but not sure of the solution yet..

          The following header resolves my problem:

          $headers .= "From: conference@toastmasters.org.pt \r\n" ."X-Mailer: php \n";

          BUT I want to use the following header:

          $headers .= "From: conference 2011 conference@toastmasters.org.pt \r\n" ."X-Mailer: php \n";

          so that the from field displays the text "conference 2011" instead of the from address.

          How do I correct this?

          tx

            What I meant is the complete headers from the email address that you receive.

            If you use the php [man]mail[/man] function then you delegate the sending of mail to the operating system, usually via sendmail. This results in the email being sent from some default email address dictated by your server's operating system.

            The problem you are having with getting "conference 2011" into your email address is that you need to use some brackets or parentheses or something. I'm not sure of the exact format. I just checked an email header I got from facebook and it would appear that you put angle brackets <> around the email address:

            From: Facebook <update+hjhv3j7_@facebookmail.com>

              The brackets should do the trick.

              I'm also curious about your use of "\n" as opposed to "\r\n" in a couple of cases. I need to study the relevant RFC or something, but some SMTP servers (like qmail) complain about "\n" as "bare linefeeds".

                The proper line ending is "\r\n" - it should be used in all headers.

                The problem is that some SMTP MTA's attempt to be smart (when in reality they're actually dumb for doing this) and like to translate "\n" (a line feed) to "\r\n" (the proper CRLF sequence that SMTP protocol expects). Why? I dunno... perhaps the reasoning is that "\n" is the standard Unix line break, so they figure that the input on a Unix system will only have "\n".

                Either way, the only time you'd want to use "\n" as a line break is if you have such a dumb MTA, otherwise the proper "\r\n" sequence will get translated into "\r\r\n" and cause problems.

                  Write a Reply...