David Felton wrote:
The Win32 implementation of mail() is notoriously flaky. the approach I take is to write the raw email directly out to the pickup folder in mailroot. A function along these lines should help you out:
function sendMail($mailto, $mailfrom, $subject, $text, $format) { $maildrop="c:\\inetpub\\mailroot\\pickup\\";//change this to the location of your mailroot
$filename=<work out some random filename here>; $fp=fopen($maildrop.$filename, "w");
//different headers for different mail types if($format=="plain") fwrite($fp,"Content-Type: text/plain\r\nFrom: $mailfrom\r\n"); else if($format=="html") fwrite($fp,"Content-Type: text/html; charset=iso-8859-1\r\nFrom: $mailfrom\r\n");
//write the email out to the file fwrite($fp,"To: <$mailto>\r\n"); fwrite($fp,"Subject: $subject\r\n"); fwrite($fp,"\r\n"); fwrite($fp,"$text\r\n\r\n"); fclose($fp); }
hope that helps.
-----Original Message----- From: Andy Tawse [mailto:andy.t@xxxxxxxxxxxxxxxxxxxxxx] Sent: 24 May 2004 10:14 To: php-windows@xxxxxxxxxxxxx Subject: windows mail problem
Hi there,
I've been having difficulty sending emails from Windows machines. I've seen this problem in a few places before but I can't seem to fix it on my machine. When I try to use mail() I get :
mail(): "sendmail_from" not set in php.ini or custom "From:" header missing
The code I'm using is :
$headers = "From: $email\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Reply-To: $email\r\n"; $headers .= "X-Priority: 3\r\n"; $headers .= "X-MSMail-Priority: Normal\r\n"; $headers .= "X-Mailer: My Application";
$ok = @mail($friendMail, $CHALLENGE_MAIL_SUBJECT, $mailText, $headers);
This has worked on my linux server before. It is saying I haven't set a From header but as you can see I have and my php.ini looks like this :
[mail function] ; For Win32 only. SMTP = localhost sendmail_from = my@xxxxxxxxx
The mail server is running and should be accepting connections. I've tried the IIS SMTP server and also Argosoft, set both of them to accept connections but it doesn't seem to get as far as the SMTP server.
I've tried it on my local machine (XP Pro, IIS 5, PHP 4.3.6) and on the production server (Win 2003, IIS 6, PHP 4.3.6). I've restarted and done all the things I've found suggested for this problem but no joy.
Can anyone help?
Thanks for your time,
Andy Tawse.
--
Andy Tawse | Head Programmer New Media Collective | www.newmediacollective.com andy.t@xxxxxxxxxxxxxxxxxxxxxx 0870 4202313 | 07958 578399
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php