Jump to content

PHP mail()function


rabbitsfeat

Recommended Posts

Hi everyone, I'm very new to PHP and have started by following the tutorials on w3schools.

 

I'm getting on ok but have run into a problem concerning the email tutorial. See here: http://www.w3schools.com/php/php_mail.asp

 

I've entered this code as they've said:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someoneelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

 

And I'm getting this 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\contact.php on line 27

Mail Sent.

 

I think it has something to do with my PHP setup and an .ini file, but other than that I have no idea! Please can somebody help me?

 

I'm running the apache server on my computer on windows XP Home edition... if that helps.

 

Cheers and hope to be a regular around here as my knowledge of PHP improves.

Link to comment
Share on other sites

This just means that you aren't running any mailserver software. The easiest thing to do is to open up php.ini and change the SMTP  setting from localhost to your isp's smtp server, i.e smtp.myisp.tld. Then restart apache.

Link to comment
Share on other sites

is the server linux and did you set it up so have full root access then you could configure sendmail to send to your isp's SMTP

do you have a email account with your ISP then you can proberly access your ISP SMTP server by SMTP.[isp].com replace [isp] with your isp address AOL would be smtp.aol.com

 

Scott.

Link to comment
Share on other sites

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.