RichG Posted February 27, 2008 Share Posted February 27, 2008 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 Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/ Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 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) ?> Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478599 Share on other sites More sharing options...
cooldude832 Posted February 27, 2008 Share Posted February 27, 2008 its great how you define "$headers" and then fail to use it in the mail() function Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478603 Share on other sites More sharing options...
redarrow Posted February 27, 2008 Share Posted February 27, 2008 http://uk.php.net/mail go here there all there m8 Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478612 Share on other sites More sharing options...
RichG Posted February 27, 2008 Author Share Posted February 27, 2008 I put the $headers in and the email would not send. The form submitted and nothing comes through? Why would this do that. Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478613 Share on other sites More sharing options...
cooldude832 Posted February 27, 2008 Share Posted February 27, 2008 mail doesn't fatally error its a function it returns a TRUE or FALSE on completing i.e <?php if(mail($to,$from,$subject,$headers){ #It went } else{ #It failed } ?> Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478617 Share on other sites More sharing options...
RichG Posted February 28, 2008 Author Share Posted February 28, 2008 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 Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-478912 Share on other sites More sharing options...
cooldude832 Posted February 28, 2008 Share Posted February 28, 2008 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."; } ?> Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-479324 Share on other sites More sharing options...
RichG Posted March 7, 2008 Author Share Posted March 7, 2008 cool thanks it is working now Link to comment https://forums.phpfreaks.com/topic/93418-tied-up-in-knots-with-html-in-php-email-response/#findComment-485991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.