php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20625 Mail Function output displaying '>' before the word From
Submitted: 2002-11-25 10:59 UTC Modified: 2002-11-26 06:25 UTC
From: sarah at perceptiondesign dot net Assigned:
Status: Not a bug Package: *Mail Related
PHP Version: 4.2.0 OS: Free BSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sarah at perceptiondesign dot net
New email:
PHP Version: OS:

 

 [2002-11-25 10:59 UTC] sarah at perceptiondesign dot net
* PHP version is actually 4.1.2 but Server is hosted with NTT/Verio so unable to update PHP version

I am testing my mail function where a user enters their subject and message on a form and the next page pulls emails from a database and mails out to everyone. When I put the word From in the message box in the format From.. or From then on.. or From Sat 16th. it displays a '>' before the word From like this >From then on.. 
It doesn't do this with lower case from or upper case.  It is ok when you insert a space before writing From.

I thought it might be getting mixed up with the From tag.  My code is this:

 <?php
	  	echo "Emails have been sent to the following people: <br><br>";
		$header = "From: Blair Drummond Safari Park <info@blairdrummond.com>\n";
		$header .= "Content-Type: text/html\n"; 
	  	$db = mysql_connect("localhost", "******", "******"); 
		mysql_select_db("******",$db);
		$result = mysql_db_query("******","select * from consumers where email<>'' and email <> ' ' and mailing<>-1");
		while ($row = mysql_fetch_array($result)) {
			echo $row["email"]." (".$row["first_name"]." ".$row["surname"].") ";
			mail($row["email"],$subject,$message,$header);
		}	 
	  ?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-25 12:58 UTC] iliaa@php.net
Your code has a slight problem that I see, the 'From:' header contain a newline between the name & the email, that may cause problems for your code.
 [2002-11-25 17:56 UTC] sniper@php.net
This is not bug in PHP but in your code..please ask support elsewhere.

 [2002-11-26 04:37 UTC] sarah at perceptiondesign dot net
I have tried taking the new line breaks out of my previous code but am still getting the same result.  I have taken the code below from phpbuilder.com and put in my email address and the message "From then on" and the output was the same: >From then on 

<?php
	   mail("sarah@perceptiondesign.net", "the subject", "From then on",
       "From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());
       
	  ?>
 [2002-11-26 04:40 UTC] derick@php.net
It has to do with the unix mailbox format.

"From " at the beginning of a line is the seperator for emails in such a box, and to make sure normal lines with "From " at the beginning of a line are prefixed with a  ">".

Derick
 [2002-11-26 06:25 UTC] sarah at perceptiondesign dot net
Fixed the problem by replacing all instances of "From " with "<b></b>From " and this seems to work.  Thanks for your help Derrick.

<?php
		$xmessage = str_replace ("From ", "<b></b>From ", $message);
		
	  	echo "Emails have been sent to the following people: <br><br>";
		$header = "From: Blair Drummond Safari Park <info@blairdrummond.com>\n";
		$header .= "Content-Type: text/html\n";
	  	$db = mysql_connect("localhost", "safa16", "tybfg+nfcvf"); 
		mysql_select_db("safa16",$db);
		$result = mysql_db_query("safa16","select * from bd_consumers where email<>'' and email <> ' ' and mailing<>-1");
		while ($row = mysql_fetch_array($result)) {
			echo $row["email"]." (".$row["first_name"]." ".$row["surname"].") ";
			mail($row["email"],$subject,nl2br($xmessage),$header);
		}	 
	  ?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 21:01:29 2024 UTC