Question:
PHP email help?
Davin S
2008-01-18 09:13:15 UTC
I want to create a feeback form in PHP... I have done most of the configuration, but when i run the file i seem to be getting an 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:\wamp\www\Project\contact.php on line 12

In the php.ini file i am using the following configurations,

SMTP = smtp.mail.yahoo.com

sendmail_from = davinsamji@yahoo.co.uk


Below is the contact.php file that i have created that should send the file;

$username = $_POST['username'];
$useradd = $_POST['useradd'];
$comments = $_POST['comments'];

$to = "davinsamji@yahoo.co.uk";
$re = "contact us";
$msg = "comments";
$mailheaders = "From: My Site \n";
$mailheaders .= "Reply-To: " .$_POST["useradd"];
mail($to, $re, $msg, $mailheaders);

?>
Four answers:
Shell Answer Man
2008-01-18 09:33:32 UTC
The mail function isn't gonna work with Yahoo. Yahoo's SMTP servers require authentication (your yahoo user name and password), which mail doesn't support. Aside from that, if you don't have Yahoo's "PLUS" enhanced service, you can't use yahoo as your SMTP server.



There are several PHP scripts that support authentication for outgoing SMTP - i seem to recall "PHPMAIL"



Good luck
ballarke
2008-01-18 17:25:08 UTC
Sounds like you may need to just restart the HTTP service. If this script is running on a web server that is typically running 24-7, just shut down and restart the service. This should get the server using the modified php.ini configuration instead of the one it may already have loaded into memory.



You should also read the PHP documentation on the mail function to ensure you're meeting any other requirements.
TristanVR
2008-01-18 17:32:31 UTC
Something seems wrong. The script error says it is having a problem connecting to a mail server at localhost. Do you have a mail server running on localhost? Yet, you say your php.ini has SMTP set to point to 'smtp.mail.yahoo.com' but that does not appear to be where the PHP script is pointing.

The other thing to check is if you can connect to smtp.mail.yahoo.com. Go to the command line or shell and telnet to smtp.mail.yahoo.com 25 to see if it connects. All you want to know is if it connects. Hosting companies and ISPs often protect access to SMTP servers to prevent spam.
BIG FOOT
2008-01-18 17:36:49 UTC
You dont have mail server installed on your computer...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...