Jump to content

Tied up in knots with html in php email response


RichG

Recommended Posts

Hi Guys

 

I have been reading some posts on html in email form responses and I am getting a bit lost. The email gets sent but it just puts the html code into the mail content. Can anyone see where i am going wrong.

 

$link = 'www.richdgrimes.co.uk/phptest/login.php';

 

 

$toaddress = $regemail;

$Subject = 'Thank you for registering with us';

$body = "<html>"

        ."<head>"

."<title>Test Mail</title>"

."</head>"

."<body>"

."Thank you for registering with XYZ. Here is your username and password <br />"

."Username:" .$regname. "<br />"

."Password:" .$password. "<br />"

."Please click on the following link to login to your account" .$link. "<br />"

."</body>"

."</html>";

 

 

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$from = 'Email from XYZ Models';

 

mail($toaddress, $subject, $body, $from);

 

I get no errors on submitting the form just can't get the html to work

 

Cheers

RichG

trie that m8..

<?php


$link = 'www.richdgrimes.co.uk/phptest/login.php';   
            
         
   $toaddress = $regemail;
   $Subject = 'Thank you for registering with us';
   $body = $text;
   
   $text="<html>"
           ."<head>"
      ."<title>Test Mail</title>"
      ."</head>"
      ."<body>"
      ."Thank you for registering with XYZ. Here is your username and password
"
      ."Username:" .$regname. "
"
      ."Password:" .$password. "
"
      ."Please click on the following link to login to your account" .$link. "
"
      ."</body>"
      ."</html>";
         
         
   $headers = 'MIME-Version: 1.0' . "\r\n";
   $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";                                 
   $from = 'Email from XYZ Models';
         
   mail($toaddress, $subject, $body, $from)
   
?>

OK tried a few things now and stil not having much success. Can you look at this code and tell me what iw wrong as the confirmation if() at the end is saying the mail attempt failed.

 

//This section will email confirmation to user with password and also email admin new user has registered

 

//change this to your email.

    $to = $regmail;

    $from = 'XYZ';

    $subject = "Hello! This is HTML email";

 

    //begin of HTML message

    $message = "<html>

<body> 

        Looool!!! I am reciving HTML email......<br>

        Thanks Richard!<br>

        <a href="http://www.richdgrimes.co.uk">XYZ</a>

        <br><br>*** Now you Can send HTML Email <br> Regards<br>Richard

  </body>

</html>";

  //end of message

 

    // To send the HTML mail we need to set the Content-type header.

    $headers = "MIME-Version: 1.0rn";

    $headers .= "Content-type: text/html; charset=iso-8859-1rn";

    $headers  .= "From: $from\r\n"; 

   

    // now lets send the email.

    if(mail($to, $subject, $message, $headers))

{

echo 'it went';

exit;

}

else

{

echo 'it failed';

exit;

}

 

I do have <php in there i have not pasted it because there is a lot more code in the document.I am just stuck on the mail bit.

 

Cheers

RichG

this is my generic email bit

<?php
$domain = "http://www.mysite.com";
$subject = "Generic Mailer";
$headers = "From: ".$domain." <info@".$domain.">\r\n";
$headers .= "Reply-To: info@".$domain."\r\n";
$headers .= "Return-Path: info@".$domain."\r\n";
$headers .= "BCC: [email protected]\r\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\r\n";
$message = "
	This is a auto-generated message please do not respond to it.";
if(mail($values['email'],$subject,$message,$headers)){
	echo "It sent.";
}
else{
	echo "It failed.";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.