用到了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. python3编码问题

    继续收集python3编码问题相关资料 资料来源  鹏程的新浪博客(转载)http://blog.sina.com.cn/s/blog_6d7cf9e50102vo90.html  这篇鹏程老师写的关 ...

  2. poj 2342 Anniversary party 树形DP入门

    题目链接:http://poj.org/problem?id=2342 题意:一家公司有1 <= N <= 6 000个职工,现要组织一些职工参加晚会,要求每个职工和其顶头上司不能同时参加 ...

  3. 一个优秀php程序员应具备什么样的能力

    1:php能力 1.1 熟悉 一种或者几种框架,并可以用于开发 1.2 了解 这些框架中的优点与缺点 1.3 假如要你选择框架,你会使用哪种最适合你开发 2:数据库能力 2.1:能写一些简单的sql语 ...

  4. MVC5添加控制器总是报“Multiple object sets per type are not supported”

    http://www.asp.net/mvc/tutorials/mvc-5/introduction/creating-a-connection-string 按照上面的指导做练习,  总报小面的错 ...

  5. Nhibernate 一对多,多对一配置

    先来分析下问题,这里有两张表:Users(用户表) U和PersonalDynamic(用户动态表) PD,其中PD表的UserId对应U表的Id 如图: 现在映射这两张表: 如图: User.hbm ...

  6. Mongodb FAQ 存储(storage)篇

    1.什么是内存映射文件(memory mapped files)? 内存映射文件是操作系统通过调用函数mmap()创建的一个放在内存中的一个数据文件.这种文件可以当做一个从零开始的内存或者数组,你可以 ...

  7. [转载]WCF 几种常见错误

    WCF标准的配置文件为: <system.serviceModel>         <services>             <service name=" ...

  8. [转载]C#.NET中Dns类的常用方法及说明

    IP是一种普遍应用于因特网.允许不同主机能够相互找到对方的寻址协议.IP地址由4个十进制的数字号码所组成,而每一个号码的值介于0~255之间,它虽然解决了网络上计算机的识别问题,但是IP地址确不容易记 ...

  9. 练习--LINUX进程间通信之信号SIGNAL

    同样的,信号也不要太迷信可靠信号及不及靠信号,实时或非实时信号. 但必须要了解这些信号之间的差异,函数升级及参数,才能熟练运用. ~~~~~~~~~~~~~~~~ 信号本质 信号是在软件层次上对中断机 ...

  10. 关于 ASP.NET MVC 4 如果管理用户

    很久没上来写博客,因为自己没写博客的日子里去学了一下OBJECTIVE-C 和 ASP.NET MVC.最近在学ASP.NET MVC 4,有个问题一直在困扰着我,就是怎样管理用SIMPLE MEMB ...