Php mail() function not working

Code examples

0
0

php mail if successful

$result = mail('[email protected]', 'Test Subject', $message);
if(!$result) {   
     echo "Error";   
} else {
    echo "Success";
}
0
0

mail function php not working

Although there are portions of this answer that apply to only to the usage of themail() function itself, many of these troubleshooting steps can be applied to any PHP mailing system.

There are a variety of reasons your script appears to not be sending emails. It's difficult to diagnose these things unless there is an obvious syntax error. Without one you need to run through the checklist below to find any potential pitfalls you may be encountering.
0
0

php test if mail is working

<?php 
$email = "[email protected]";
$subject =  "Email Test";
$message = "my mail test message";
$sendMail = mail($email, $subject, $message);
if($sendMail){ 
	echo "Email Sent Successfully";
}else{
	echo "Mail Failed";
}
#If the mail() function exist but mails not going, check if a mail transport agent (MTA)such as sendmail or postfix is installed on your server
?>
0
0

mail() function in php not working

CONFIGURE THESE SETUPS:

in your php.ini:
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"


in your sendmail.ini
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................