如何检查客户端服务器是否允许邮件发送?


How can i check mail sending is allowed in client's server

在我的网站上有一些邮件选项。在这里我发送html邮件。所以我需要检查我的客户端服务器是否支持邮件功能。我该如何检查这个?如果有php代码的话

so you want to check mail() is supporting into client's server?

if(function_exists('mail'))
{
}

但是,我确信这种方法是不推荐的,最好的检查方式,发送一个空消息给你自己:

<?php
if(mail($to,$subject,$message) != false)
{
   echo 'You can send email';
}
?>

您只能检查邮件是否发送:

<>之前 $message = "Line 1'nLine 2'nLine 3"; // Send if(mail('YOUR_EMAIL_HERE@example.com', 'My Subject', $message)) { echo "Sent"; } else { echo "Not Sent"; }

试试下面的代码

<>之前 if(mail('TEST_ACCOUNT@gmail.com','test','content') != false) { echo 'You can send email from this server'; }else{ print_r(error_get_last()); }