Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unable to get new lines using PHP Mailer

Posted on 2009-05-06
4
Medium Priority
?
680 Views
Last Modified: 2013-12-13
Hi all, I am writing a form to email script and using PHP Mailer to do it. I am brand new to PHP Mailer and only a little familiar with PHP.

My issue is that I am unable to get 'new lines' (i.e. carriage returns) in my emails. I have tried \n\n,  \r\n  double quotes, single quotes, but just can't figure it out!

I have attached the key lines from my code..... can you help?!?!
$mailheader = 'Thank you for your interest in xyz. \n\n";	
$mailfooter = "Please do not reply to this message as it is sent from an automated system. If you wish to contact us for any reason, please visit our web site at etc etc"."\r\n";
$mailcombined = $mailheader.$mailfooter;
 
$mail = new PHPMailer();
	$mail->IsSMTP(); // send via SMTP
	$mail->Host     = $mailhost; // SMTP servers
	$mail->SMTPAuth = true; // turn on SMTP authentication
	$mail->Username = $mailusername; // SMTP username
	$mail->Password = $mailpassword; // SMTP password
	$mail->From = $mailfrom;
	$mail->FromName = $mailfromname;
	$mail->AddAddress("stuart@domain.co.uk"); 
	$mail->WordWrap = 50; // set word wrap
	$mail->IsHTML(true); // send as HTML
	$mail->Subject  =  $mailsubject;
//	$mail->Body     =  "body";
	$mail->Body     =  $mailcombined;
	$mail->AltBody  =  $mailcombined;
    $mail->Send();

Open in new window

0
Comment
Question by:AbacusInfoTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
ycTIN earned 2000 total points
ID: 24316554
you settings is send html
$mail->IsHTML(true); // send as HTML

in the HTML, line break is <br>

\n and \r\n just working in Plain Text mode

$mail->IsHTML(false) // send as Plain Text
0
 
LVL 1

Author Comment

by:AbacusInfoTech
ID: 24316602
Doh! <br><br> Yes, well spotted. <br><br> Thanks!
0
 
LVL 6

Expert Comment

by:0791882310
ID: 24316650
$mailheader = 'Thank you for your interest in xyz. ";      
$mailfooter = "Please do not reply to this message as it is sent from an automated system. If you wish to contact us for any reason, please visit our web site at etc etc";
$mailcombined = $"" . mailheader . "\n\n" . $mailfooter . "\r\n";

try that.....
0
 
LVL 1

Author Comment

by:AbacusInfoTech
ID: 24316672
Have already assigned points but thanks anyway. I'm happy with the solution but out of interest I will go back and try the plain text code too.... thanks!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question