#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Edinburgh
    Posts
    19
    Rep Power
    0

    Email Form sending the emailer a copy


    Hi there

    I have managed to get so far with my email form and it send to both the admin and also the email address entered for the sender.

    But, the admin email is received in HTML and looks fine but when the sender receives the email its all HTML code and is unreadable.

    Can someone please help me as i don't understand why this is happening.

    Thanks in advance

    Code:
    <?php
    
    $senderName   = $_POST['userName'];
    $senderEmail     = $_POST['userEmail'];
    $senderSubject   = $_POST['userSubject'];
    $senderMessage = $_POST['userMsg'];
    
    $senderName   = stripslashes($senderName);
    $senderEmail     = stripslashes($senderEmail);
    $senderMessage   = stripslashes($senderMessage);
    
          $to  = 'email address goes here' . ', ';
    	  $to .= $senderEmail;
    	  
        $from = "$senderEmail ";
        $subject = "$senderSubject";
        $message = <<<EOF
    <html>
      <body bgcolor="#FFFFFF">
    <b>Name</b> : $senderName<br /><br />
    <b>Email</b> : <a href="mailto:$senderEmail">$senderEmail</a><br /><br />
    <b>Subject</b> : $senderSubject<br /><br />
    <b>Message</b> : $senderMessage<br />
      </body>
    </html>
    EOF;
       
        $headers  = "From: $from\r\n";
        $headers .= "Content-type: text/html\r\n";
        $to = "$to";
    
        mail($to, $subject, $message, $headers, $senderEmail);
        
    exit();
    ?>
    thanks

    Hudbarnett
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    Please use [ PHP ] tags rather than [ CODE ] tags for your PHP. See the sticky at the top of this forum.

    The reason has nothing to do with your PHP per se. The reader being used either is not capable of rendering HTML or has HTML turned off. This is a real world situation thus it requires you to modify your email to accommodate it.

    You need to generate a multi-part email that can be rendered either with an HTML capable reader or a plain text reader. This should help.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Edinburgh
    Posts
    19
    Rep Power
    0
    Originally Posted by gw1500se
    Please use [ PHP ] tags rather than [ CODE ] tags for your PHP. See the sticky at the top of this forum.

    The reason has nothing to do with your PHP per se. The reader being used either is not capable of rendering HTML or has HTML turned off. This is a real world situation thus it requires you to modify your email to accommodate it.

    You need to generate a multi-part email that can be rendered either with an HTML capable reader or a plain text reader. This should help.
    Thank you for getting back to me, i'll check out the link.

    Thanks

    Hudbarnett

IMN logo majestic logo threadwatch logo seochat tools logo