PHPMailer DEMO

<?php  
    require 'class.phpmailer.php';

    try {
        $mail = new PHPMailer(true); //New instance, with exceptions enabled

        $body = " ";

        $mail->IsSMTP();             
        $mail->SMTPAuth   = true; 
        $mail->Port       = 25;     
        $mail->Host       = "smtp";
        $mail->Username   = "mail"; 
        $mail->Password   = "pass";   

        $mail->From       = "mail";
        $mail->FromName   = "mail";

       	$mail->AddAddress("mail1");
      	$mail->AddAddress("mail2");
        
        $mail->Subject  = '';

        $mail->MsgHTML($body);

        $mail->IsHTML(true); // send as HTML
		/* 附件的路径和附件名称 */
        $mail -> AddAttachment('/data/'.$csvName.'.csv',$csvName.'.csv');

        $mail->Send();

        echo 'Message has been sent.';

    } catch (phpmailerException $e) {
        echo $e->errorMessage();
    }

?>
 

你可能感兴趣的:(phpmailer)