问题
In my site there have some mailing options.Here iam sending an html mails. So i need to check wheather my client's server support the mail function or not. How can i check this? If there is any php code for this ?
回答1:
so you want to check mail() is supporting into client's server?
if(function_exists('mail'))
{
}
But, i'm sure this method is not recommended, the best way to check, send an empty message to your self:
<?php
if(mail($to,$subject,$message) != false)
{
echo 'You can send email';
}
?>
回答2:
You can only check whether mail is sent or not:
$message = "Line 1\nLine 2\nLine 3";
// Send
if(mail('YOUR_EMAIL_HERE@example.com', 'My Subject', $message)) {
echo "Sent";
}
else {
echo "Not Sent";
}
回答3:
Try below code.
if(mail('TEST_ACCOUNT@gmail.com','test','content') != false)
{
echo 'You can send email from this server';
}else{
print_r(error_get_last());
}
来源:https://stackoverflow.com/questions/8655035/how-can-i-check-mail-sending-is-allowed-in-clients-server