Menu

Recipient sees wrong From address!

Help
eschamp
2007-07-15
2013-06-03
  • eschamp

    eschamp - 2007-07-15

    The form HTML file says:

           <tr>
                <td>Email Address</td>
                <td><input name='Email' type=text size="40" /></td>
           </tr>

    process.php says

    ....
    $message="Email: ".$Email."
    Name: ".$Name."
    Address: ".$Address."
    Phone: ".$Phone."
    ";

    $message = stripslashes($message);
    mail("4SAM-NJ-subscribe@yahoogroups.com, pjh@hidden.com","SUBSCRIBE",$message,"From: $Email");
    ?>

    The second addressee (pjh@hidden.com) gets an email from the email address that's in $Email, but 4SAM-NJ-subscribe@yahoogroups.com gets one from user "pjh" at the machine that hosts the script!

    "We are unable to process the message from <pjh@arkanoid.dreamhost.com>
    to <4SAM-NJ-subscribe@yahoogroups.com>."

    However, when I send a message from <pjh@arkanoid.dreamhost.com>
    to <4SAM-NJ-subscribe@yahoogroups.com> directly, everything works OK.

    ???

     
    • TNTEverett

      TNTEverett - 2007-07-16

      You can look here for the syntax of th email function.
      http://us2.php.net/manual/en/function.mail.php

      For the email format issue, you must have the mail clients setup differently.  This of course depends on what you mean when you say "unable to process the message".  This is not very descriptive. 

       
      • eschamp

        eschamp - 2007-07-16

        The problem is that YahooGroups thinks that the sender is pjh@arachnoid.dreamhost.com, not the address that's in $Email

        Assuming that the correct syntax is

        mail("4SAM-NJ-subscribe@yahoogroups.com, pjh@hidden.com","SUBSCRIBE",$message,$FROM);

        would you suggest an assignment statement that would give to $FROM the value it needs to present the correct string to mail(), namely From: followed by the email address that's contained in $Email?

        Thanks.

         
    • TNTEverett

      TNTEverett - 2007-07-16

      Here is a copy of modifications I made to one of my forms that may help you.  The $message piece is shortened for the example.  The message can be text only or html as I have done.  It is the $headers that you are most interested in.  It defines the complete header information you would need to specify a specific "From" address and make the message reciept more consistent by specifically stating the content type.  Normally your "From" address is fixed.  You want the from address to be from you or your site.  It is dangerous to allow form fields to populate the header fields in your mail function without some sort of protection.  Do this with caution and protect your forms, and your site, from being used to send spam. 

      pt_register('POST','Email');
      pt_register('POST','SubjectBrokerOrderForm');

      $headers = "MIME-Version: 1.0\r\n".
         "Content-type: text/html; charset=iso-8859-1\r\n".
         "From: \&quot;youraddress@yourdomain.com\&quot;\r\n".
         "Date: ".date("r")."\r\n";
      $message="
      <html>
      <body>
      <table border=\&quot;1\&quot; width=\&quot;100%\&quot; id=\&quot;table1\&quot;>
        <tr>
          <td width=\&quot;357\&quot;><font face=\&quot;Arial\&quot;>
          <b>Subject Broker Order Form:</b></font></td>
          <td><font face=\&quot;Arial\&quot;>
          ".$SubjectBrokerOrderForm."</font></td>
        </tr>
      </table>
      </body>
      </html>
      ";
      $message = stripslashes($message);
      mail($Email, "Copy of your order form", $message,$headers);

       
      • eschamp

        eschamp - 2007-07-16

        Regardless of the danger, I would like the From: to be the value of the $Email variable. Would you kindly show me how to do that? (I'll take care of the protection once I have some success here.) Thanks.

         
        • TNTEverett

          TNTEverett - 2007-07-17

          $headers = "MIME-Version: 1.0\r\n".
          "Content-type: text/html; charset=iso-8859-1\r\n".
          "From: ".$Email."\r\n".
          "Date: ".date("r")."\r\n";

           
    • eschamp

      eschamp - 2007-07-17

      Thank you!

      As far as security goes (and I appreciate your concern), the form is on a password-protected page.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.