Raz3rt Posted June 20, 2014 Share Posted June 20, 2014 I have a strange problem with my headers in my mail function. This is how it looks like in my code: $to = 'someone@email.com'; $subject = 'Question from website'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=UTF-8' . "\r\n"; $headers .= 'From: ' . $email . "\r\n"; When i send this i got the following message in my mailbox: Content-type: text/html;charset=UTF-8 From: web@somecompany.com Message-Id: <20140620142808.93D11A147@apache11.hostbasket.com> Date: Fri, 20 Jun 2014 16:28:08 +0200 (CEST) <html><head><title>Question from web</title><style type="text/css">body {background-color: #ffffff; font-family: verdana;}hr {color: #333;}div {width: 800px; margin: 25px auto;}h1 {color: #FFC421; font-size: 17px;}p {color: 2a2a2a; font-size: 15px;}</style></head><body><div><p><img src="imgs/tsc-logo.png"/></p><hr /><h2 style="color: #FFC421;">This customer asked a question</h2><br /><table style="width:800px"><tr><th style="width:250px"><h1>Customer:</h1></th><td></td></tr><tr><th>Name:</th><td>testname</td></tr><tr><th>Firstname:</th><td>testfirstname</td></tr><tr><th>E-mail:</th><td>testperson@company.be</td></tr><tr><th>Bericht:</th><td>This is a test</td></tr></table></div></body></html> I have allready found that the space between "Content-type" and "From" is not normal that indicates that a rule between MIME and Content-type is also present. But in my code there isn't any rule... How can this be possible? Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/ Share on other sites More sharing options...
Ansego Posted June 20, 2014 Share Posted June 20, 2014 (edited) Hi Raz3rt Nothing jumps out at me, though 4am... Could you please show us the full mail code. This is what I use in my headers: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Take over the world Reminder <totw@example.com>' . "\r\n"; Worth trying a different header. Are you also sure the SMTP/POP3 server is setup correctly? Edited June 20, 2014 by Ansego Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/#findComment-1482953 Share on other sites More sharing options...
ginerjm Posted June 21, 2014 Share Posted June 21, 2014 As Ansego said - show us how you send the mail. Very important piece you forgot to show us. Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/#findComment-1482976 Share on other sites More sharing options...
Raz3rt Posted June 23, 2014 Author Share Posted June 23, 2014 (edited) Hello, thank you for the answers. Here is my full code copy pasted fram my project (it's in Dutch language, sorry for that!) if ($_SERVER['REQUEST_METHOD'] == 'POST'){ if (!empty($_POST['email'])) { $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING); $firstname = filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING); $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); $info = filter_input(INPUT_POST, 'info', FILTER_SANITIZE_STRING); $message = '<html><head>'; $message .= '<title>Vraag vanaf de website</title>'; $message .= '<style type="text/css">body {background-color: #ffffff; font-family: verdana;}hr {color: #333;}div {width: 800px; margin: 25px auto;}h1 {color: #FFC421; font-size: 17px;}p {color: 2a2a2a; font-size: 15px;}</style>'; $message .= '</head>'; $message .= '<body>'; $message .= '<div>'; $message .= '<p><img src="imgs/tsc-logo.png"/></p>'; $message .= '<hr />'; $message .= '<h2 style="color: #FFC421;">Klant heeft een vraag gesteld via de website</h2>'; $message .= '<br />'; $message .= '<table style="width:800px">'; $message .= '<tr><th style="width:250px"><h1>Gegevens klant:</h1></th><td></td></tr>'; $message .= '<tr><th>Naam:</th><td>' . $name . '</td></tr>'; $message .= '<tr><th>Voornaam:</th><td>' . $firstname . '</td></tr>'; $message .= '<tr><th>E-mail:</th><td>' . $email . '</td></tr>'; $message .= '<tr><th>Bericht:</th><td>' . $info . '</td></tr>'; $message .= '</table>'; $message .= '</div>'; $message .= '</body></html>'; $to = 'someone@telenet.be'; $subject = 'Vraag vanop de website'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=UTF-8' . "\r\n"; $headers .= 'From: ' . $email . "\r\n"; if (mail($to, $subject, $message, $headers)){ $_SESSION['email'] = $email; header ('Location: index.php?pagina=send'); } else { header ('Location: index.php?pagina=404'); } } } Could it be a problem with the host where the website is hosted? Edited June 23, 2014 by Raz3rt Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/#findComment-1483052 Share on other sites More sharing options...
Raz3rt Posted June 23, 2014 Author Share Posted June 23, 2014 Edit: I just tried it on an other demo host and there it works! So no problem with the code... it's a pitty it doesn't support changing the headers Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/#findComment-1483053 Share on other sites More sharing options...
ginerjm Posted June 23, 2014 Share Posted June 23, 2014 Is you mail client ready to receive html mail? It's an option often. Quote Link to comment https://forums.phpfreaks.com/topic/289221-problem-with-headers-in-mail-function-html-format/#findComment-1483079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.