Marc7777 Posted June 11, 2007 Share Posted June 11, 2007 I have a 'tell a friend' php script in a website and the owner gets an email when a user tells a friend about the website. This is the code that sends the email to the owner of the website as text: if($receiveNotifications) { $subject = 'Tell a friend script notification'; $message = 'This person: ' . $_POST['name'] . ' (' . $_POST['email'] .')' . "\r\n" . $message = ' told a friend about our website. E-mailaddrres(es) of his or her friend(s): ' . implode(', ', $sent) . "\r\n" . $message = "Personal message: " . $_POST['message']; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From: ' . $webmasterEmail . "\r\n" . 'X-Mailer: Company Name'; @mail($webmasterEmail, $subject, $message, $headers); } This works fine and the email looks as follows: This person:: Xxxxc (xxx@xxxx.com) told a friend about our website. E-mailaddrres(es) of his or her friend(s): xxxx@hotmail.com Personal message: Hello Test What I can not get done is to insert linebreaks so that the email looks as follows: 'This person: Xxxxc (xxx@xxxx.com) told a friend about our website. E-mailaddrres(es) of his or her friend(s): xxxx@hotmail.com Personal message: Hello Test I thought adding "\r\n" . would create the needed linebreaks nor do I get linebreaks if I use "\n\n". Please help! Thanks. Marc Quote Link to comment https://forums.phpfreaks.com/topic/55079-solved-linebreak-problem-with-email-notification/ Share on other sites More sharing options...
chrisuk Posted June 11, 2007 Share Posted June 11, 2007 here is some code from one of my projects which works as expected: <?php $messageproper = "A new user account has been created for you \n" . "Details are as Follows:\n" . "--------------------------\n\n" . "You Username: $username\n\n" . "Your Password: $password\n\n" . "For security purposes you should log in and change your password to something more memorable as soon as possible\n\n" . "This email has been automatically generated, please do not reply. If you have any issues, please contact your system administrator" . "\n\n\n" ; ?> Notice how we have used the . operator differently - perhaps that is where the problem lies but I couldn't say for sure as this is the only way I have ever done it. You could perhaps adopt a similar format...hope that's of any use. Quote Link to comment https://forums.phpfreaks.com/topic/55079-solved-linebreak-problem-with-email-notification/#findComment-272262 Share on other sites More sharing options...
Marc7777 Posted June 11, 2007 Author Share Posted June 11, 2007 Thanks fr your help! But it didn't solve the problem. The solution was in the header which was set to html $headers = 'Content-type: text/html; charset=utf-8 instead of $headers = 'Content-type: text/plain; charset=utf-8' Quote Link to comment https://forums.phpfreaks.com/topic/55079-solved-linebreak-problem-with-email-notification/#findComment-272313 Share on other sites More sharing options...
chrisuk Posted June 11, 2007 Share Posted June 11, 2007 Didn't spot that never mind at least it's sorted Quote Link to comment https://forums.phpfreaks.com/topic/55079-solved-linebreak-problem-with-email-notification/#findComment-272315 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.