• php 发送smtp邮件


    需要下载PHPMailer/PHPMailerAutoload.php这个类。调用如下:

    <?php
     $id = 1105;
     $fromName = '张三';
     $html = '测试内容';
     $subject = '测试标题';
     $toMail = '2256285375@qq.com';
     $replyTo = '925546266@qq.com';
     $from = 'qqsanji@info.mailufo.com';
     require_once 'PHPMailer/PHPMailerAutoload.php';
     $mail = new PHPMailer;
     $mail->Charset = 'utf-8';
     $mail->Encoding = 'base64';
     $mail->isSMTP();
     $mail->Host = '';//ip保密
     $mail->Port = 25;
     $mail->SMTPAuth = true;
     $mail->Username = '';//账号保密
     $mail->Password = 'f2409d3b';
     if (!empty($filePath) && file_exists(ROOT_PATH . $filePath)) {
      $mail->AddAttachment(ROOT_PATH . $filePath, $file_name);
     }
     $mail->AddCustomHeader('X-Scedm-Tid', $id);
     $mail->Sender = $from;
     $mail->setFrom($from, "=?utf-8?B?" . base64_encode($fromName) . "?=");
     $mail->addAddress($toMail);
     $mail->addReplyTo($replyTo, "=?utf-8?B?" . base64_encode($fromName) . "?=");
     $mail->isHTML(true);
     $mail->Subject = "=?utf-8?B?" . base64_encode($subject) . "?=";
     $mail->MsgHTML(htmlspecialchars_decode(htmlspecialchars_decode($html)));
     $mail->AltBody = '';
     $a = $mail->send();
     var_dump($a);
     //smtp表密码userinfo_edm_trigger
     if(!$a){
      $msg = $mail->ErrorInfo;
      var_dump($msg);
     }
  • 相关阅读:
    源代码的下载和编译
    搭建Android开发环境
    Git使用入门
    Android系统构架
    Android深度探索心得<9>
    Android深度探索心得<10>
    Android深度探索心得<8>
    android深度探索xinde < 7>
    android深度探索xinde < 5>
    android深度探索xinde < 6>
  • 原文地址:https://www.cnblogs.com/ayanboke/p/8625050.html
Copyright © 2020-2023  润新知