All,
If someone can help in this , it will be great.
I am trying to send mail from php using the below code.
<?php
$to = "sriram_s_98@yahoo.com";
$from = "sriram_s_98@yahoo.com";
$subject = "This is a test email";
$message = "Dear John,\n\nThis is a fake email, I hope you enjoy it.\n\nFrom Jane.";
$headers = "From: $from\r\n";
$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?>
I get the following error message.
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\Apache Group\Apache2\htdocs\phpmail.php on line 9
An error occurred when sending the email to sriram_s_98@yahoo.com from sriram_s_98@yahoo.com
I am using windows XP client OS running on Apache webserver.
Can someone let me know where I am going wrong.
Regards
Php Mail
Moderator: General Moderators
Php Mail again
Thanks for the response.
But after I installed Argosoft mail I get this error in response.
Warning: mail() [function.mail]: SMTP server response: 551 User not local. We don't relay in C:\program files\Apache Group\Apache2\htdocs\phpmail.php on line 9
An error occurred when sending the email to sriram_s_98@yahoo.com from sriram_s_98@yahoo.com
What changes do I have to do in php.ini.
Also is there a way I can find out what is using my localhost address?
But after I installed Argosoft mail I get this error in response.
Warning: mail() [function.mail]: SMTP server response: 551 User not local. We don't relay in C:\program files\Apache Group\Apache2\htdocs\phpmail.php on line 9
An error occurred when sending the email to sriram_s_98@yahoo.com from sriram_s_98@yahoo.com
What changes do I have to do in php.ini.
Also is there a way I can find out what is using my localhost address?
You do not need to have an smtp server installed on your machine running PHP.
Even though we run exchange, I wouldn't dream of routing my nice PHP-generated email through exchange.
You can just use your ISPs SMTP server. The one you specify in outlook/express/eudora/thunderbird for when you send email, in your email account settings.
To tell PHP to use your ISPs mail server, do the following...
In php.ini search for the text [mail function]
That's the bit in my php.ini on windows 2000.
Remove the semi-colon in front of the SMTP = and smtp_port = values.
And change smtp.isp.com to whatever your ISPs smtp/outgoing mail server is.
Then change sendmail_from = to whatever email address you want emails sent using mail() to appear as if they're sent from.
Note that if you specify a different 'From: ' header in the mail() function, then that will override the sendmail_from variable in php.ini
So there's only two little changes you need to make in php.ini to get it working.
HTH
Batfastad
Even though we run exchange, I wouldn't dream of routing my nice PHP-generated email through exchange.
You can just use your ISPs SMTP server. The one you specify in outlook/express/eudora/thunderbird for when you send email, in your email account settings.
To tell PHP to use your ISPs mail server, do the following...
In php.ini search for the text [mail function]
Code: Select all
їmail function]
; For Win32 only.
SMTP = smtp.isp.com
smtp_port = 25
; For Win32 only.
sendmail_from = administrator@domain.com
; For Unix only. You may supply arguments as well (default: "e;sendmail -t -i"e;).
;sendmail_path =Remove the semi-colon in front of the SMTP = and smtp_port = values.
And change smtp.isp.com to whatever your ISPs smtp/outgoing mail server is.
Then change sendmail_from = to whatever email address you want emails sent using mail() to appear as if they're sent from.
Note that if you specify a different 'From: ' header in the mail() function, then that will override the sendmail_from variable in php.ini
So there's only two little changes you need to make in php.ini to get it working.
HTH
Batfastad