zoukankan      html  css  js  c++  java
  • phpmailer 发送邮件

    <?php
    /*
    可用新浪和网易邮箱测试成功,但QQ不成功!
    下载 phpmailer 解压
    http://phpmailer.worxware.com/
    
    要注意邮件服务器的端口号,默认是 25 不用修改,如果不是则要修改如下,在$mail->IsSMTP() ;下一行加上 $mail->Port = 端口号;
    */
    require 'class.phpmailer.php';
    
    $mail = new PHPMailer;
    
    $mail->IsSMTP();   // Set mailer to use SMTP
    
    $mail->Host = 'smtp.sina.com';  // SMTP 服务器 Specify main and backup server
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'mysina';                            // SMTP username
    $mail->Password = '******';                           // SMTP password
    $mail->SMTPSecure = '';                            // Enable encryption, 'ssl' also accepted
    
    $mail->From = 'mysina@sina.com';
    $mail->FromName = 'mysina';
    $mail->AddAddress('0000000@qq.com', 'Josh Adams');  // Add a recipient
    //$mail->AddAddress('ellen@example.com');               // Name is optional
    $mail->AddReplyTo('mysina@sina.com', 'Information');
    //$mail->AddCC('cc@example.com');
    //$mail->AddBCC('bcc@example.com');
    
    $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
    //$mail->AddAttachment('/var/tmp/file.tar.gz');         // Add attachments
    //$mail->AddAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->IsHTML(true);                                  // Set email format to HTML
    
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    
    if(!$mail->Send()) {
       echo 'Message could not be sent.';
       echo 'Mailer Error: ' . $mail->ErrorInfo;
       exit;
    }else{
         echo 'Yes';
    }
    

      

  • 相关阅读:
    Jenkins 插件管理
    持续集成 目录
    gitlab 目录
    jenkins 目录
    POJ 2828
    POJ 2782
    POJ 2725
    POJ 2769
    POJ 2739
    POJ 2707
  • 原文地址:https://www.cnblogs.com/lin3615/p/3603925.html
Copyright © 2011-2022 走看看