Jump to content

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

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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