用到了swiftmailer 的lib库

官方网址:http://swiftmailer.org/

require_once 'lib/swift_required.php';
//给我发送邮件
function mailer(){
    $body ="要发送的内容";
    $subject = "要发送主题"

$transport = Swift_SmtpTransport::newInstance('smtp.qq.com', 25);//设置发送 smtp 服务器和端口
    $transport->setUsername('发送邮箱 地址 ');
    $transport->setPassword('发送邮箱密码');
    $mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance();
    $message->setFrom(array( '发送邮箱地址'  =>'发送人'));
    $message->setTo(array('接受邮箱地址' => '接受人'));
    $message->setSubject($subject);
    $message->setBody($body, 'text/html', 'utf-8');
    //$message->attach(Swift_Attachment::fromPath('pic.jpg', 'image/jpeg')->setFilename('rename_pic.jpg'));//发送附件
    try{
        $mailer->send($message);
    }
    catch (Swift_ConnectionException $e){
        echo 'There was a problem communicating with SMTP: ' . $e->getMessage();
    }
}

Swift 直接与 SMTP 服务器通讯,具有非常高的发送速度和效率。

Swiftmailer的特点:

  1. Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
  2. Support servers that require username & password and/or encryption
  3. Protect from header injection attacks without stripping request data content
  4. Send MIME compliant HTML/multipart emails
  5. Use event-driven plugins to customize the library
  6. Handle large attachments and inline/embedded images with low memory use

PHP使用SwiftMailer发送邮件的更多相关文章

  1. SwiftMailer 发送邮件时 提示fsockopen() 被禁用

    站点转移空间,发送邮件的SwiftMailer 类提示错误如下: Warning: fsockopen() has been disabled for security reasons in D:\1 ...

  2. thinkphp 整合 swiftmailer 实现邮件发送

    thinkphp swiftmailer(phpmailer) 文件夹结构 图 1 swiftmailer-phpmailer 将swiftmailer整合到thinkphp中.如上图 1 我下载的版 ...

  3. yii2-user 一个好用的用户扩展

    最近使用yii2做了一个系统,涉及到了用户登录等等,之前是自己写的一套,后来要添加邮箱验证功能.有点懒,然后看到了yii2-user这个扩展.简单说下,毕竟自己研究也不深. http://yii2-u ...

  4. Yii2 advance swiftmailer 不能发送邮件

    我用的是Yii2高级模板,在配置好邮箱后,并编写测试,测试结果表明是发送成功的,但我的邮箱就是接受不了邮件. 经过排查发现,是由 common/config/main-local.php 文件的 'u ...

  5. yii2 发送邮件 yii\swiftmailer\Mailer

    Yii2 中发送邮件 yii\swiftmailer\Mailer 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath ...

  6. 分享一个php邮件库——swiftmailer

    最近看到一个好的php邮件库,与phpmailer作用一样,但性能比phpmailer好,尤其是在处理附件的能力上,发送邮件成功的几率也高. github地址:https://github.com/s ...

  7. ThinkPHP 3.2.3 使用 Swift Mailer 邮件系统发送邮件

    SwiftMailer 下载地址:https://github.com/swiftmailer/swiftmailer 版本:swiftmailer-5.x 把压缩包解压到 /ThinkPHP/Lib ...

  8. yii2发送邮件教程

    作者:白狼 出处:http://www.manks.top/article/yii2_swiftMailer本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接, ...

  9. [moka同学笔记]YII2中发送邮件示例(转载)

    原文:http://yiilib.com/topic/675/Yii2%E4%B8%AD%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6%E7%A4%BA%E4%BE%8B { ...

随机推荐

  1. ECSHOP 订单状态 记录

    记录订单状态 order_status /* 订单状态 */ define(‘OS_UNCONFIRMED’,            0); // 未确认 define(‘OS_CONFIRMED’, ...

  2. Linux下实现流水灯等功能的LED驱动代码及测试实例

    驱动代码: #include <linux/errno.h> #include <linux/kernel.h> #include <linux/module.h> ...

  3. 安装cocoaPods遇到的坑

    第一个坑 更换ruby源后,安装cocoaPods是出现以下错误:activesupport requires Ruby version >= 2.2.2 Ruby version >= ...

  4. 如何使用Promise

    在说Promise之前,不得不说一下JavaScript的嵌套的回调函数 在JavaScript语言中,无论是写浏览器端的各种事件处理回调.ajax回调,还是写Node.js上的业务逻辑,不得不面对的 ...

  5. Android开发(一):环境搭建

    引言 本系列将记录我在步入Android开发过程中的一些流水账及经验,如有疏漏,还望不吝赐教. 目录 1.JDK安装及配置 2.Eclipse.Android SDK ADT安装及配置 正文 1.JD ...

  6. SQL Server 修改排序规则

    Net stop mssqlserver Setup /QUIET /ACTION=REBUILDDATABASE /instancename=mssqlserver /SQLSYSADMINACCO ...

  7. mysql function 与 procedure

    Mysql 的 function 和 procedure 有啥区别呢 ? 网上搜索后说 function 有返回值, procedure 无返回值. 1.return  从function 的语法角度 ...

  8. poj 1811 Prim test

    基本上一个裸的Miller_Rabin大素数判定和一个裸的Pollard_rho素数分解算法,当模板用吧! #include<cstdio> #include<algorithm&g ...

  9. Oracle SQL tuning 步骤

    Oracle SQL tuning 步骤 SQL是的全称是Structured Query Language(结构化查询语言).SQL是一个在80年代中期被使用的工业标准数据库查询语言.不要把SQL语 ...

  10. Linux 系统挂载数据盘

    适用系统:Linux(Redhat , CentOS,Debian,Ubuntu) *  Linux的云服务器数据盘未做分区和格式化,可以根据以下步骤进行分区以及格式化操作. 下面的操作将会把数据盘划 ...