Djrikidk Posted July 13, 2010 Share Posted July 13, 2010 Hi there. I've been trying to figure this out for weeks, and i've been pissed off so many times because it works for anyone else except me.. I use the mail(); function in PHP, and this is my code: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: MafiaSoul <[email protected]>'; $to = '[email protected]'; $subject = 'Activation E-mail'; $message = 'This is your activation E-mail'; mail($to, $subject, $message, $headers); The code works fine on my server hosted by JustHost, but since i am building on the same code on my localhost i want to be able to send mails form there too. But it can't. I've asked on 3 other forums and they replied with all kinds of advanced intel which i didn't understand at all and i am new to this stuff so please go easy on me with the advanced stuff... Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/ Share on other sites More sharing options...
kenrbnsn Posted July 13, 2010 Share Posted July 13, 2010 What's the error? Ken Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/#findComment-1085317 Share on other sites More sharing options...
ram4nd Posted July 13, 2010 Share Posted July 13, 2010 use smtp??? Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/#findComment-1085328 Share on other sites More sharing options...
Djrikidk Posted July 13, 2010 Author Share Posted July 13, 2010 This is the error i get: 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:\xampp\htdocs\MafiaSoul\index.php on line 2511 Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/#findComment-1085330 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2010 Share Posted July 13, 2010 The reason you are getting an error that tells you "Failed to connect to mailserver at "localhost" port 25" is because you don't have a mail server installed on your localhost computer. Even if you did install and configure a mail server on your localhost computer, you would only be able to send emails to yourself on it unless you also have a domain name and proper DNS records on a public name server that point to your localhost computer. If you are just doing this for testing your mail code, either do it on your live server or use one of the phpmailer classes that allow you to use SMTP authentication (the php mail() function does not support SMTP authentication) and use the mail server on your live host. Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/#findComment-1085358 Share on other sites More sharing options...
Djrikidk Posted July 13, 2010 Author Share Posted July 13, 2010 Ok, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/207598-i-keep-getting-an-error-when-i-try-to-send-mail/#findComment-1085419 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.