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
https://forums.phpfreaks.com/topic/179952-php-unable-to-sent-email/
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 <[email protected]>";

it doesn't work either.

 

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

 

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.

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.