note 106877 deleted from function.mail by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:10:27 +0000 |
| Subject: | note 106877 deleted from function.mail by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218235@lists.php.net to get a copy of this message | ||
Note Submitter: debis at woh dot rr dot com
----
This is for Windows Server 2003, IIS 6.0 with SMTP virtual server.
The problem I had was not including init_set for the SMTP server, I thought the SMTP definition in
the IIS SMTP virtual server configuration would work. When I sent mail manually this was not an
issue.
Also, $mail_sent = @mail( $to, $subject, $message, $headers ); wouldn't work but $mail_sent =
mail($to, $subject, $message, $headers); did.
Lack of date_default_timezone_set() only caused a warning because php guessed what it should be.
This worked:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set ( "SMTP", "smtp-server.example.com" );
date_default_timezone_set('America/New_York');
mail($to, $subject, $message, $headers);
?>
And just so you can troubleshoot, this worked when sending mail from the command line/manually. CLI
worked even though the php code without the init_set function wouldn't work.
You will notice that the "rcpt to" and "to" fields appear redundant, but if both
are not used, the delivered mail's "to" field will be blank/empty.
-------------------------------
telnet www.example.com 25
helo
mail from: webmaster@example.com
rcpt to: someone@example.com
data
to: someone@example.com
subject: test again to make sure
this is my message
.
quit
-----------------------------------