Mail Problem

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
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Mail Problem

Post 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";
?>
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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?
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Post 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?
Last edited by tsalexey544 on Fri Jun 23, 2006 5:06 am, edited 1 time in total.
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Your SMTP server isn't running. Are you windows or Linux?
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Post by tsalexey544 »

Windows
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Post 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]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

You need to change the SMTP setting in your php.ini
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Post by tsalexey544 »

how and were?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
tsalexey544
Forum Commoner
Posts: 41
Joined: Thu Jun 22, 2006 11:19 am

Post by tsalexey544 »

OK thanks a LOT!!!! :lol:
Post Reply