Mail() in IIS5/SMTP
Moderator: General Moderators
Mail() in IIS5/SMTP
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!
<?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!
You need to put From: before the email address... $mail_from = "From:Testing@PHP.com";
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!
<?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!
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!";
}
?>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...
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...
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.
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.
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
<?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()
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... 