call to mail() doesn't work in Windows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

call to mail() doesn't work in Windows

Post by jasongr »

Hello people

I am using the following code to try to send an email:

Code: Select all

$to = "test@test.com";
$subject = "This is a test";
$message = "This is the message body";
$header = "From: John Smith <johnsmith@test.com>";
mail($to, $subject, $message, $header);
This code works fine when I run it on a Linux machine.
It does not work when I try it on a Windows machine

I have SMTP server installed

Is there something wrong in the mail format? including the body and the headers for Windows?

any help would be appreciated
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

can you send mail through the smtp server from a mail client?

in other words, are you sure the smtp server works?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

.... and have you got full error reporting on, including notices?
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post by jasongr »

I was able to get it to work by modifying the header to

Code: Select all

$header = "From: johnsmith@test.com";
Appearantly there is a problem with the first and last name and the usage of <>
Post Reply