Web Hosting Talk







View Full Version : PHP mail() on Windows


peachtreewebworks
11-18-2002, 04:31 PM
Anyone got the mail() function in PHP working on a Windows server? Here's some sample code:



PHP:--------------------------------------------------------------------------------

<?
$go = "<font face=arial size=2>This is a test.<br>Just a test.</font>";
$headers = "Wrom: SNBOHMKHJYFMYXOEAIJJPHSCRTNHGSWZ
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

$to = "mail@yourdomain.net";
$subject = "Test Email";
$mailmessage = $go . "<font face=arial size=2><a href='http://www.yahoo.com</a></font>";

$mailsomeone = mail($to, $subject, $mailmessage, $headers);
?>

--------------------------------------------------------------------------------


This works fine in Linux, but not Windows - generates a server error at the mail() line. I've tried adding the following to the php.ini file with no success:

[mail function]
SMTP = mail.mydomain.net
sendmail_from = me@mydomain.net
cgi.force_redirect = 0

Any ideas?

Marty
11-18-2002, 05:05 PM
Do you have a mail server running on the Windows machine?

If so, then change

SMTP = mail@mydomain.net

to

SMTP = localhost

peachtreewebworks
11-18-2002, 06:14 PM
Originally posted by Marty
Do you have a mail server running on the Windows machine?

Nope... the mail server is a seperate dedicated server.

Thanks though...

Ratty
11-19-2002, 02:11 AM
Try setting SMTP to whatever the MX record for your domain is (normally mail.mydomain.net or mailhost.mydomain.net)

ie :

SMTP = mail.mydomain.net

Marty
11-19-2002, 11:30 AM
Originally posted by Ratty
Try setting SMTP to whatever the MX record for your domain is (normally mail.mydomain.net or mailhost.mydomain.net)

ie :

SMTP = mail.mydomain.net

Correct. SMTP is supposed to be set to the address of the mail server and not to an email address.

peachtreewebworks
11-19-2002, 11:38 AM
Sorry... actually had it that way but retyped it wrong. (Edited original post above)

interactive
11-20-2002, 08:58 PM
this may sound stupid but just setup iis smtp...would work wonders ;-)

peachtreewebworks
11-20-2002, 09:24 PM
Originally posted by interactive
this may sound stupid but just setup iis smtp...would work wonders ;-)
Not sure if that was sarcastic or not, but, SMTP is setup correctly. All of the asp pages that use CDONTS or any other setup sends the email via the SMTP server with no problem.

jtrovato
11-22-2002, 02:32 PM
I have noticed that alot of things do not work correctly on windows boxes. I had trouble getting it to work too, so all I did was change the SMTP in the php.ini. You said that you did that and it still didn't work. Would this be a testing server or a production server? I wish I could help more, but I do everything on *nix boxes now.

Good luck

John