mail.php

来自「发送邮件 phpmailer 非常简单好用」· PHP 代码 · 共 36 行

PHP
36 行
字号
<?
require_once(dirname(__FILE__).'/phpmailer/class.phpmailer.php'); //phpmailer

function SmtpMail($send_to_mail,$subject,$body,$extra_hdrs,$username){
    $mail=new PHPMailer();
    $mail->IsSMTP();                
    $mail->Host="mail.163.com";    
    $mail->SMTPAuth=true;         
   $mail->Username="username";      
   $mail->Password="password";      
    $mail->From="username@163.com";  
    $mail->FromName="username";        
    $mail->CharSet="UTF-8";        
    $mail->AddAddress($send_to_mail,"$username");              
    $mail->AddReplyTo("username@163.com","name");    
    $mail->IsHTML(true);            
    $mail->Subject=$subject; 
	  

    $mail->Body="<html><head>
                 <meta http-equiv='Content-Language' content='zh-cn'>
                 <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head>
                 <body background>$body
                 </body>
                 </html>";
    $mail->AltBody="text/html";       
    if (@ !$mail->Send()) {
        $results=array("result"=>false,"message"=>$mail->ErrorInfo);
        return $results;
    }else{
        $results = array("result"=>true,"message"=>"send success to {$send_to_mail}");
        return $results;
    }
}

?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?