Answers for "php mail test"

28

php mail

<?php
$to = $_POST['email'];
$subject = "Email Subject";

$message = 'Dear '.$_POST['name'].',<br>';
$message .= "We welcome you to be part of family<br><br>";
$message .= "Regards,<br>";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";

mail($to,$subject,$message,$headers);
?>
Posted by: Guest on May-28-2020
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
?>
Posted by: Guest on November-24-2020
0

php mail if successful

$result = mail('[email protected]', 'Test Subject', $message);
if(!$result) {   
     echo "Error";   
} else {
    echo "Success";
}
Posted by: Guest on November-26-2020

Browse Popular Code Answers by Language