Jump to content

[SOLVED] linebreak problem with email notification


Marc7777

Recommended Posts

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 ([email protected]) told a friend about our website. E-mailaddrres(es) of his or her friend(s):  [email protected] Personal message: Hello Test

 

What I can not get done is to insert linebreaks so that the email looks as follows:

 

'This person: Xxxxc ([email protected]) told a friend about our website.

E-mailaddrres(es) of his or her friend(s):  [email protected]

 

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

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.

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.