Jump to content

php unable to sent email


shihao

Recommended Posts

Hi, guys, I try to send a email through php but unfortunately the mail unable to sent. Here is my code, any configuration that I need to change in order to send the email ? Anyone who know please help ? Thanks in advance.

 

<?// send e-mail to ...

$to="me@localhost";

 

// Your subject

$subject="Test";

 

// From

$header="from: your name <your email>";

 

// Your message

$message="Hello \r\n";

$message.="This is test\r\n";

$message.="Test again ";

 

// send email

$sentmail = mail($to,$subject,$message,$header);

 

// if your email succesfully sent

if($sentmail){

echo "Email Has Been Sent .";

}

else {

echo "Cannot Send Email ";

}

?>

 

The error message "Cannot Send Email" shown

Link to comment
Share on other sites

Hi, seanlim, how to turn on the php error report, there is many php.ini file. I didn't use xampp, I had configure seperately.

This is my php.ini,

C:/php/php.ini ,

C:/program Files/apache group/apache2/php.ini

C:/windows/system32/php.ini

C:/Apache/htdocs/phpmyadmin/php.ini

 

and which script that I shall change it?

 

phpretard, I had change it to $header="from: phpretard <ngshihao@yahoo.com>";

it doesn't work either.

 

Link to comment
Share on other sites

hi scvinodkumar,

 

I just want to do at my own PC, localhost.

Now my parameter is

SMTP: localhost

SMTP_port: 25

 

The error message that I get is:

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\mail.php on line 20

 

Link to comment
Share on other sites

You will need to install and run an SMTP server on your PC then. I have not attempted this before, but I believe it isn't hard.

 

The alternative would be simply to use your ISP's SMTP server, which is what I do when I need to test out PHP mail functions on localhost.

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.