php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9859 mail() doesn't send cc or bcc as in the manual instructions
Submitted: 2001-03-20 02:42 UTC Modified: 2001-05-22 03:33 UTC
From: joel at intwebservices dot com Assigned:
Status: Closed Package: Mail related
PHP Version: 4.0.4pl1 OS: Windows NT 4.0
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: joel at intwebservices dot com
New email:
PHP Version: OS:

 

 [2001-03-20 02:42 UTC] joel at intwebservices dot com
script example:
-------------------------------------------------------------------------------------------------
<?php
$returnvar="false";
		
$mailto="you@yourdomain.com";
$mailsubject="cc test";
$mailmessage="message content";
$mailHeader="cc:otheraddress@yourdomain.com\r\n";
		
$returnvar=mail($mailto,$mailsubject,$mailmessage,$mailHeader);	
	
?>
<html>
<body>
the mail was sent?
<?php
echo "<br>returnvar= $returnvar<br>";
?>
</body>
</html>
---------------------------------------------------------------------------------
The above does not send the carbon copy.

The pdf manual says:
----------------------------------------------------------------------------------------------------------
$headers .= "cc:birthdayarchive@php.net\n"; // CC to
$headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCCs to
/* and now mail it */
mail($recipient, $subject, $message, $headers);
-----------------------------------------------------------------------------------------------------------

That does not work since Win32 sendmail.c looks for case sensitve "Cc:"
sendmail.c also does not look for "bcc:"

Also you must have "\r\n" not just "\n".

I think the problem is here in win32 sendmail.c :

	if (headers && (pos1 = strstr(headers, "Cc:"))) {
		pos2 = strstr(pos1, "\r\n");
		tempMailTo = estrndup(pos1, pos2-pos1);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-21 05:06 UTC] danbeck@php.net
I've corrected the Cc: and Bcc: problems in the mail() example, but I'm reclassifying this as a Mail Function problem.  Is it necessary for the win32 version of the mail() function to require that you use \r\n? 

If it is, I can add this information to the mail function docs.
 [2001-05-22 01:45 UTC] bbonev@php.net
see also bug #10136

the facts are: mail on win32 require \r\n newlines
also it is case sensitive on Cc: and Bcc: - it will not honour them if spelled any other way.

here is the offending code (located in win32/sendmail.c):

if (headers && (pos1 = strstr(headers, "Cc:"))) {
  pos2 = strstr(pos1, "\r\n");
  tempMailTo = estrndup(pos1, pos2-pos1);
  token = strtok(tempMailTo, ",");

i do not have win32 build env setup so cannot fix this
 [2001-05-22 03:33 UTC] danbeck@php.net
If this is the case, then I'm closing this bug report and I will document the behavior under the mail function.
 [2003-03-19 04:02 UTC] admin at aesirnetworks dot com
<?php 
print mail('admin@aesirnetworks.com', 
    'Subject', 'Your message here.', 
    "To: The Receiver <admin@aesirnetworks.com>\n" . 
    "From: The Sender <admin@aesirnetworks.com>\n" . 
    "Cc: Interested <mike@aesirinteractive.com>\r\n" . 
    "X-Mailer: PHP 4.x"); 
?>

Fails to send with any combination of \r\n or \n, and CC, cC,Cc, and etc. Basically we are are unable to send with CC at all.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 00:01:41 2024 UTC