PHP发送电子邮件功能不再有效

时间:2015-06-17 14:39:06

标签: php email

最近我注意到我的PHP发送电子邮件功能无效。

以下是我发送电子邮件的功能。

function sendHTMLemail($HTML,$from,$to,$subject,$x){

// First we have to build our email headers
// Set out "from" address

$headers = "From: $from\r\n"; 

// Now we specify our MIME version

$headers .= "MIME-Version: 1.0\r\n"; 

// Create a boundary so we know where to look for
// the start of the data

$boundary = uniqid("HTMLEMAIL"); 

// First we be nice and send a non-html version of our email

$headers .= "Content-Type: multipart/alternative;".
            "boundary = $boundary\r\n\r\n"; 
//
$headers .= "This is a MIME encoded message.\r\n\r\n"; 

$headers .= "--$boundary\r\n".
            "Content-Type: text/plain; charset=ISO-8859-1\r\n".
            "Content-Transfer-Encoding: base64\r\n\r\n"; 

$headers .= chunk_split(base64_encode(strip_tags($HTML))); 

// Now we attach the HTML version

$headers .= "--$boundary\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n\r\n"; 

$headers .= chunk_split(base64_encode($HTML)); 

// And then send the email ....


if(mail($to, $subject, "", $headers)){
            return " ";
        }else{
            return "error"."-".$to."";
        }   
    }

我没有编写代码,以前的开发人员做过。

0 个答案:

没有答案
相关问题