Page 1 of 1

Mail Problem

Posted: Fri Jun 23, 2006 3:53 am
by tsalexey544
Why does this script isn't working?
It looks ok

Code: Select all

<?php
$to = "spam@yahoo.ca";
$subject = "Spamming Is Great";
$body = "Spam is one of the best scripting languages around";
$headers = "From: Arrest@FBI.com\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
?>

Posted: Fri Jun 23, 2006 4:52 am
by jamiel
Try

Code: Select all

$headers = "From: Arrest@FBI.com\r\n";
Otherwise, does it work when you remove the headers? And do you get any errors or does the mail just not arrive?

Posted: Fri Jun 23, 2006 5:03 am
by tsalexey544
I get this:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\DzSoft\PHP Editor\phpB4.tmp on line 16
Mail sent to spam@yahoo.ca


I checked my mail after 10 min and there were no new mail.

Could you plz write a working script for sending mail?

Posted: Fri Jun 23, 2006 5:05 am
by jamiel
Your SMTP server isn't running. Are you windows or Linux?

Posted: Fri Jun 23, 2006 5:07 am
by tsalexey544
Windows

Posted: Fri Jun 23, 2006 5:09 am
by tsalexey544
Your SMTP server isn't running. Are you windows or Linux?
I am tesitng the script on my computer. I installed PHP and nothing alse.[/quote]

Posted: Fri Jun 23, 2006 5:11 am
by JayBird
You need to change the SMTP setting in your php.ini

Posted: Fri Jun 23, 2006 5:11 am
by tsalexey544
how and were?

Posted: Fri Jun 23, 2006 5:14 am
by JayBird

Posted: Fri Jun 23, 2006 5:17 am
by jamiel
Otherwise if you are on XP, check if you have the SMTP service installed ... Control Panel --> Adminstrative Tools --> Services --> Look for Simple Mail Transfer Protocol (SMTP) and start it up.

Posted: Fri Jun 23, 2006 5:24 am
by tsalexey544
OK thanks a LOT!!!! :lol: