Jump to content

I keep getting an error when i try to send mail


Djrikidk

Recommended Posts

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.. :shrug:

 

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...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.