Solved

How to put End of Line with PHP - Sendmail ?

Posted on 2008-10-12
3
288 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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.
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 …

734 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