Re: Problems with mail on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Luis Ferro wrote:


My PHP.INI: SMTP = smtp.example.com sendmail_from=server@xxxxxxxxxxx


You have to chance the php.ini configuration to point out to the smtp server and use as sender one valid account there.


The current configurations you have in php.ini are the example ones and need to be changed... (either directly or by the use of set_ini() function...).

Luis, this is not an error. PHP.INI is well set, and the adresses I
wrote here were changed for example purposes.

The main problem is when sending mail from Windows with the mail()
function and using and SMTP server. The mail function modifies the TO
header (CC and BCC also). The change made by the mail function does not
conform with the RFC 2822 (wich obsoletes 822), and then the SMTP server
does not accept the mail because headers are incorrectly formed.

Here the examples: (Note that all examples work perfect on Linux, only
fails on windows)

mail("someone@xxxxxxxxxxx", $subject, $text);		// WORKS
mail("My Name <someone@xxxxxxxxxxx>", $sub, $txt);	// FAILS

Also, the function fails when you write additional headers with the Cc:
and Bcc: Fiels in the same format:

$header = "Cc: Someone Name <someone@xxxxxxxxxxx\r\n";
$header .= "Bcc: Someother Name <anybody@xxxxxxxxxxx\r\n";
mail("someone@xxxxxxxxxxx", $sub, $txt, $header);	// FAILS

All this headers follow the RFC 2822, and the SMPT server would accept
them with no problems. (And it really does). The problem is that the PHP
mail layer on windows changes this headers encolsing them betwen the
signs <>.

Looking at the SMTP dialog, you can see that the mail() function
encloses all adresses betwen <>, and then the address are:

To: <someone@xxxxxxxxxxx>
To: <My Name <someone@xxxxxxxxxxx>>
Cc: <Someone Name <someone@xxxxxxxxxxx>>
Bcc: <Someothe Name <anybody@xxxxxxxxxxx>>

What's the problem? Main problem is when the function starts sending
mail, because it modifies the additional headers. Modifiying the To:,
Cc: and Bcc: fields ... and then using the modified addresses in the
RCPT TO comand to send the mail.

The SMTP standard, stated on RFC 2821, expects only the email address on the RCPT TO: command. This command MUST be formed this way:
RCPT TO:<someone@xxxxxxxxxxx>


But PHP sends all the To: field in the form:
RCPT TO:<Someone Name <someone@xxxxxxxxxxx>>
wich does not conform the standard.

Then, the same SMTP standard, expects all headers (Without any modification) to be sent in the DATA section:

DATA

From: Jordi Canals <llistes@xxxxxxxxxxxx>
To: Someone Name <someone@xxxxxxxxxxx>

... so, in my opinion, the mail layer should extract the e-mail adrresses to send the RCPT commands, and leave the headers with no changes to send them in the SMTP DATA section.

Regards,
Jordi.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux