Page 1 of 1
Mail() in IIS5/SMTP
Posted: Sun Jan 18, 2004 6:59 pm
by Flash05
Question regarding PHP/iiS5/SMTP. I'm testing my script for my mail form:
<?php
$mail_to = "
testing@yahoo.com";
$mail_subject = "Testing";
$mail_body = "Test body...";
$mail_from = "
Testing@PHP.com";
if(mail($mail_to, $mail_subject, $mail_body, $mail_from))
echo "Successfully sent the e-mail \"$mail_subject\" to $mail_to.";
else echo "Failed to send the e-mail \"$mail_subject\" " . "to \"$mail_to\""
?>
Yesterday, I was able to send mail. Unfortunately, when I tested my script later, it was no longer sending mail. Is there a configuration or some sort to be able for me send email? I already change my php.ini SMTP to "SMTP = localhost", to use my local smtp. My connection outside was dialup. Im using Windows XP Pro and iiS5.01. Can someone help me with this. Thanks!
Posted: Sun Jan 18, 2004 7:57 pm
by Flash05
Btw, is there special configuration or setting for iiS or smtp to be able to send again emails?
Posted: Sun Jan 18, 2004 8:19 pm
by Gen-ik
You need to put From: before the email address...
$mail_from = "From:Testing@PHP.com";
Posted: Sun Jan 18, 2004 9:14 pm
by Flash05
Tnx for the reply.
<?php
$mail_to = "
testing@yahoo.com";
$mail_subject = "Testing";
$mail_body = "Test body...";
$mail_from = "From:Testing@PHP.com";
if(mail($mail_to, $mail_subject, $mail_body, $mail_from))
echo "Successfully sent the e-mail \"$mail_subject\" to $mail_to.";
else echo "Failed to send the e-mail \"$mail_subject\" " . "to \"$mail_to\""
?>
I've changed the script according to your suggeston. It still not sending, though yesterday it was fine and was able so send email using localhost smtp. Is ther any other solution. Please help me. TNx!
Posted: Sun Jan 18, 2004 9:22 pm
by Straterra
Shouldn't there be brackets with the if statement? I also see a colon missing from the second to last line..
Posted: Sun Jan 18, 2004 9:23 pm
by Gen-ik
Hmmm.. see if this works..
Code: Select all
<?php
$mail_to = "testing@yahoo.com"; // Is this a real email address? I think it might need to be
$mail_subject = "A test email";
$mail_body = "Oooh curvey body";
$mail_from = "From:someone@somewhere.com";
$email_result = mail($mail_to, $mail_subject, $mail_body, $mail_from);
if($email_result)
{
echo "Email has been sent.";
}
else
{
echo "DOH!";
}
?>
Posted: Sun Jan 18, 2004 9:55 pm
by Flash05
TNx for reply. Your suggested code works, the result is "DOH!" It wasn't able to send the mail.
Actaully i got the code from a book and modified it. It works fine yesterday morning. When I tried it later, it no longer worked. I'm not sure what's the problem but I think it's not the code (maybe...). Maybe there is a setting in IIS?
By the way, I tried it yesterday using dialup connection (I have outside IP). Can this work even though i have a non-routable IP?
Tnx again...
Posted: Mon Jan 19, 2004 2:30 am
by Flash05
What maybe the reason behind this? I'm not sure if I made some changes yesterday to my iiS? Can someone here help me setup my iiS/smtp serveR? tnx! Thankyou also for the help in the script...

Posted: Mon Jan 19, 2004 8:05 am
by Gen-ik
Just out of interest, are you trying to run the code on-line or off-line?
I have Apache/PHP etc installed on my home computer and I made the mistake once of trying to send emails from my computer (
http://127.0.0.1) without being connected to the web... with obviously didn't work.
Posted: Mon Jan 19, 2004 7:57 pm
by Flash05
On-line. Im using XP/iis5.01. I was able to send mail and was happy about it. Turned off my pc, then when I got back to try again my script for sending email, it won't send... Strange... btw, here's d script:
<?php
$mail_to = "
testing@yahoo.com";
$mail_subject = "Testing";
$mail_body = "Test body...";
$mail_from = "From:
Testing@PHP.com";
if(mail($mail_to, $mail_subject, $mail_body, $mail_from))
echo "Successfully sent the e-mail \"$mail_subject\" to $mail_to.";
else echo "Failed to send the e-mail \"$mail_subject\" " . "to \"$mail_to\""
?>
php.ini
SMTP = localhost
Configuring my IIS/SMTP for mail()
Posted: Tue Jan 20, 2004 4:36 am
by Flash05
Newbie here... Can somebody walk me through the process of configuring my IIS's SMTP so that I can test my mail form. Im using Windows XP Pro, IIS 5.01, PHP... Thanks in advance...
