在网上找了很多资料,最后自己实践了下。
记录下来方便学习
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/
require './phpmailer/class.phpmailer.php';
require './phpmailer/class.smtp.php';
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$body = file_get_contents('contents.html'); //邮件内容
$body = preg_replace('/\\\\/','', $body); //Strip backslashes
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.163.com"; // SMTP server
$mail->Username = "XXX@163.com"; // SMTP server username
$mail->Password = "XXX"; // SMTP server password
//$mail->IsSendmail(); // tell the class to use Sendmail
$mail->AddReplyTo("XXX@163.com","javaeye"); // 回复地址
$mail->From = "xxx@163.com"; //邮箱用户名
$mail->FromName = "javaeye"; //邮箱别名
$to = "xxx@sohu.com";
$mail->AddAddress($to); //收件人地址
$mail->Subject = "First PHPMailer Message"; //标题
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mail Test</title>
</head>
Hello ,This is mail test.
<body>
</body>
</html>
邮件发送结果在附件中。
- 大小: 9.9 KB
分享到:
相关推荐
使用phpmailer发送邮件 PHP源码使用phpmailer发送邮件 PHP源码
php中用phpmailer发送邮件.pdf
使用方法: 第一步,将Mail.class.php 复制到核心扩展Lib/ORG目录或者项目的ORG目录. ...SendMail('350680013@qq.com','我能用phpmailer发送邮件了','谢谢您。。。',C('MAIL_SENDER')); PS:欢迎下载使用
使用PHPMAILER类发送邮件。使用DEMO: http://blog.csdn.net/dengxingbo/archive/2010/03/13/5377854.aspx
phpmailer 使用教程示例--配合QQ邮箱实现邮件发送功能phpmailer 使用教程示例--配合QQ邮箱实现邮件发送功能
使用PHPMailer发送邮件的DEMO
php发送邮件,可带附件和邮件体中插入图片,详情请到phpmailer 的官方网站去了解,
解压后,在send.php文件中设置自己发件及收件邮箱信息,然后就可以发送了。
PHPMailer发送邮件
phpmailer 邮件发送 phpmailer 邮件发送
phpmailer PHPmailer发送邮件
利用PHPMailer发送邮件,解决现在25端口不能发送邮件的问题。SSL465端口发送邮件。
使用PHPMAILER类发送邮件。使用PHPMAILER类发送邮件。
亲测好用。推荐下载。php发送邮件是经常用到的一个功能。这里采用PHPMailer-master专家化的程序,非常好地解决了这个问题。
PHpmailer_5.2.2-rc.zip
教你如何使用PHPMailer简单的发送邮件,轻松搞定,
PHPMailer邮件发送代码,php发送邮件源码包,直接整合
用于在PHP后端使用邮件发送功能,具体实现方法可以参考菜鸟教程,可以直接拿来用:https://www.runoob.com/w3cnote/php-phpmailer.html phpMailer 是一个非常强大的 ph p发送邮件类,可以设定发送邮件地址、回复地址...