<?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';
}

  

phpmailer 发送邮件的更多相关文章

  1. 利用PHPMailer发送邮件时报错

    利用thinkphp集成PHPMailer发送邮件时报错:Failed to connect to server: Unable to find the socket transport “ssl” ...

  2. 使用PHPmailer发送邮件的详细代码

    一.使用PHPMailer发送邮件的原因 PHP有内置的mail()方法,但是由于一些主机空间不支持该方法,所以经常会遇到无法发送邮件的情况. 所以,可以下载PHPMailer类,实现邮件发送. 二. ...

  3. ThinkPHP 中使用 PHPMailer 发送邮件 支持163和QQ邮箱等

    [摘要]ThinkPHP是一个开源的PHP框架, 是为了简化企业级应用开发和敏捷WEB应用开发而诞生的.本文介绍ThinkPHP 中使用 PHPMailer 发送邮件. PHP是自带可以发送邮件的Ma ...

  4. 在Thinkphp3.2 中使用PHPMailer 发送邮件

    phpmailer发送邮件是php开发者首选的一个邮件发送插件了,下面我来介绍怎么集成phpmailer到thinkphp框架了,有需要了解的朋友可参考. phpmailer发送邮件功能很强大,今天真 ...

  5. PHPMailer 发送邮件(二)

    发现PHPMailer又做了较大的更新,以前发送邮件的方法已不太适用,刚好要做一个实验,需要搭建个环境,这里使用Gmail进行测试,现记录下来. 传送地址Github: PHPMailer 基本要求的 ...

  6. 用phpmailer发送邮件提示SMTP Error: Could not connect to SMTP host解决办法

    之前做项目的时候做了一个用phpmailer发送邮件的功能<CI框架结合PHPmailer发送邮件>,昨天步署上线(刚开始用新浪云,嫌贵,换成阿里了),测试的时候,发送邮件却意外报错了.. ...

  7. thinkphp使用PHPMailer发送邮件

    第一步:准备PHPMailer 使用PHPMailer发送邮件,首先下载个PHPMailer 将下载的PHPMailer放到ThinkPHP文件夹里面的ThinkPHPExtendVendor 第二步 ...

  8. PHPMailer发送邮件中文附件名是乱码

    可能使用了PHPMailer发送邮件的朋友带中文附件名时会出现乱码,下面我来介绍一个解决办法. 比如我们要发送的附件是"测试.txt",如果在添加附件的时候强制使用指定文件名的方式 ...

  9. phpmailer发送邮件

    phpmailer发送邮件 PHP内置的mail函数使用起来不够方便,另外受其他语言的影响,博主更偏好面向对象的包管理模式,因此phpmailer成为了我用PHP发送邮件的首选,这里分享给大家. 库导 ...

  10. PHPmailer发送邮件时的常见问题及解决办法

    来源:http://www.chinastor.com/a/jishu/mailserver/0G392262014.html 使用PHPmailer发送邮件时的常见问题总结: 一,没有定义发送邮箱$ ...

随机推荐

  1. Python的基本语法,涵盖数据类型、循环判断、列表、map和set等

    以#开头的语句是注释 当语句以冒号“:”结尾时,缩进的语句视为代码块.一般缩进4个空格 Python程序是大小写敏感的,如果写错了大小写,程序会报错. Python的数据类型 整型 浮点型 字符串 布 ...

  2. storyboard ID

    The storyboard ID is a String field that you can use to create a new ViewController based on that st ...

  3. Android基于XMPP Smack Openfire下学习开发IM(六)总结

    不管学习什么都应该总结 这里我把关于Xmpp的一些方法整理到一个工具类中了 我就分享给大家 XmppConnection.java package com.techrare.utils; import ...

  4. iphone自定义铃声

    Step1:下载iTunes Step2:连接手机登录iTunes并授权将音乐文件添加到资料库,修改音乐时间长度为40s Step3:在主界面选择音乐标签 Step4:选择一个mp3音乐文件,点击文件 ...

  5. UserControl调用Umbraco的Data Types

    本篇文章介绍的是基于Umbraco CMS技术搭建的网站所使用的相关技术. 1.  需求: 网站前台功能有个表单提交,表单控件用到下拉列表(dropdownlist),需求是在dropdownlist ...

  6. 格式化日期时间字符串 Get-Date -Uformat , -format

    #将字符串格式化为时间格式 $dateTimeStr = '20141231T23:59:59' $format = 'yyyyMMddTHH:mm:ss' $formatProvider = [Gl ...

  7. C# richTextBox封装的一个打印的类

    附件 http://files.cnblogs.com/xe2011/CSharpWinForm_richTextBoxPrintClass.rar 在窗体上一个Richtextbox 控件 和3个按 ...

  8. python如何使用 os.path.exists()--Learning from stackoverflow 分类: python 2015-04-23 20:48 139人阅读 评论(0) 收藏

    Q&A参考连接 Problem:IOError: [Errno 2] No such file or directory. os.path.exists() 如果目录不存在,会返回一个0值. ...

  9. 【转】正确使用Block避免Cycle Retain和Crash

    原文地址:http://tanqisen.github.io/blog/2013/04/19/gcd-block-cycle-retain/ 使用指南:http://blog.csdn.net/nic ...

  10. cocos2dx_moveby_n_moveto

    对于参数(SEC, POINT)来说,CCMoveTo是移动到WND的绝对的POINT,CCMoveBy是相对当前位置移动一个相当于(0,0)到POINT的向量.