Jump to content

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 (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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.