Skip to content

Commit dacea3f

Browse files
author
Yasuo Ohgaki
committed
Fixed Bug #69874 : Can't set empty additional_headers for mail()
1 parent cc7194d commit dacea3f

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

ext/standard/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
320320
efree(f);
321321
}
322322

323-
if (hdr && php_mail_detect_multiple_crlf(hdr)) {
323+
if (hdr && strlen(hdr) && php_mail_detect_multiple_crlf(hdr)) {
324324
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Multiple or malformed newlines found in additional_header");
325325
MAIL_RET(0);
326326
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #69874: Null addtional_headers does not send mail
3+
--INI--
4+
sendmail_path=tee mailBasic.out >/dev/null
5+
mail.add_x_header = Off
6+
--SKIPIF--
7+
<?php
8+
if(substr(PHP_OS, 0, 3) == "WIN")
9+
die("skip Won't run on Windows");
10+
?>
11+
--FILE--
12+
<?php
13+
/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
14+
* Description: Send an email message
15+
* Source code: ext/standard/mail.c
16+
* Alias to functions:
17+
*/
18+
19+
echo "*** Testing mail() : send email without additional headers ***\n";
20+
21+
// Initialise all required variables
22+
$to = 'user@company.com';
23+
$subject = 'Test Subject';
24+
$message = 'A Message';
25+
26+
$outFile = "mailBasic.out";
27+
@unlink($outFile);
28+
29+
var_dump( mail($to, $subject, $message) );
30+
echo file_get_contents($outFile);
31+
unlink($outFile);
32+
33+
?>
34+
===DONE===
35+
--EXPECTF--
36+
*** Testing mail() : send email without additional headers ***
37+
bool(true)
38+
To: user@company.com
39+
Subject: Test Subject
40+
41+
A Message
42+
===DONE===

0 commit comments

Comments
 (0)