Solved

How to put End of Line with PHP - Sendmail ?

Posted on 2008-10-12
3
283 Views
Last Modified: 2008-10-13
I use mail() function of PHP to send mail to GMAIL, YAHOO...
I put <br> for End of Line
But when I view gmail, yahoo mail, The tag <br> is not change, not indicate End of line!

This is the code:

<?php

$to      = "my_gmail_acount@gmail.com";
$subject = ' Wellcome to sendmail of PHP !';
$message = '     This is line 1';
$message.= ' <br>this is Line 2 ';
$message.= ' <br>this is Line 3 ';
$headers = 'From: admin@mydomain.com' . "\r\n".
      'Reply-To: admin@mydomain.com' . "\r\n";

mail($to,$subject,$message,$headers,"-f admin@mydomain.com");  

?>

How can I resolve this problem?
Thanks in advanced!
0
Comment
Question by:star6868
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
you might want to try to use \n in addition to


<?php 
$to      = "my_gmail_acount@gmail.com";
$subject = ' Wellcome to sendmail of PHP !';
$message = '     This is line 1';
$message.= ' <br/>\nthis is Line 2 ';
$message.= ' <br/>\nthis is Line 3 ';
$headers = 'From: admin@mydomain.com' . "\r\n".
      'Reply-To: admin@mydomain.com' . "\r\n"; 
mail($to,$subject,$message,$headers,"-f admin@mydomain.com");   
?>

Open in new window

0
 
LVL 39

Expert Comment

by:Roger Baklund
Comment Utility
Use \n as angellll suggests, and REMOVE the <br/>. The latter is a html element, you are not sending an html email.
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 250 total points
Comment Utility
Also, the \n must be within double quotes:
<?php 

$to      = "my_gmail_acount@gmail.com";

$subject = ' Wellcome to sendmail of PHP !';

$message = "     This is line 1\n";

$message.= "this is Line 2\n";

$message.= "this is Line 3\n";

$headers = 'From: admin@mydomain.com' . "\r\n".

      'Reply-To: admin@mydomain.com' . "\r\n"; 

mail($to,$subject,$message,$headers,"-f admin@mydomain.com");   

?>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now