用到了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. java项目使用的DBhelper类

    import java.io.*; import java.sql.*; import java.util.*; import javax.servlet.jsp.jstl.sql.*; public ...

  2. jdbc 连接Oracle informix Mysql

    package com.basicSql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Res ...

  3. Java使用memcached

    1.加载commons-pool-1.5.6.jar.java_memcached-release_2.6.6.jar.slf4j-api-1.6.1.jar.slf4j-simple-1.6.1.j ...

  4. DB天气app冲刺第二天

    烦躁 烦躁 很烦躁 从大早起就想做一个listview的列表 到晚上也没有做好.不知道为什么.决定明天去问问同学 .做不出来太影响心情了.虽然做出来东西的感觉是很好.. 另外觉得真的没有队友是挺孤独. ...

  5. Automotive Security的一些资料和心得(2):Cryptography

    1. Security Goal - Confidentiality - Integrity - Availability - Authenticity - Non-repudiation - Aut ...

  6. VS Extension: Open Web Address with Visual Studio Browser

    使用VS 打开链接 using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; ... public ...

  7. ***PHP多线程pthreads 实现QQ号码爬虫

    通过空间历史浏览,爬出查看你空间的人(一般限制20人,除非开通黄钻),然后在爬出这20人的浏览记录,依次向下爬,你可以控制爬行深度.这里仅仅给出怕中代码片段,你可以进一步优化,将QQ分类存储.通过QQ ...

  8. 从一个脚本谈loadrunner的脚本初始化

    昨天一个同事问我,如何实现下列代码中 InputStream类is对象的实例化? * LoadRunner Java script. (Build: _build_number_) * * Scrip ...

  9. 【POJ1182】 食物链 (带权并查集)

    Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到 ...

  10. Web开发-表单验证

    表单验证是Web开发中必不可少的一个环节,用来限制用户输入数据的规范和一致性.那么如何能够简化这一任务,让开发人员通过简单的属性设置就能达到目的呢? FineUI在这一点上也是下足了功夫,比Asp.N ...