Solved

How to put End of Line with PHP - Sendmail ?

Posted on 2008-10-12
3
287 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
[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
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22696984
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
ID: 22696990
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
ID: 22696994
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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