ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2583|回复: 0

[基础操作] PHP发送邮件mail

[复制链接]
发表于 2014-11-12 19:42:42 | 显示全部楼层 |阅读模式

<?php
require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.163.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'www01networkcn@163.com';                 // SMTP username
$mail->Password = '123456';                           // SMTP password
//$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
//$mail->Port = 587;                                    // TCP port to connect to                           
$mail->Port = 25;     
$mail->CharSet = "utf-8";                //指定字符集编码,否则会乱码 by HZG 20141112
$mail->From = 'www01networkcn@163.com';
$mail->FromName = 'HZG';
$mail->addAddress('57221015@qq.com', 'Joe User');     // Add a recipient
$mail->addAddress('www01networkcn@163.com');               // Name is optional
$mail->addReplyTo('www01networkcn@163.com', 'Information');
//$mail->addCC('cc@example.com');                        //邮件抄送  by HZG 20141112
//$mail->addBCC('bcc@example.com');                //邮件抄送  by HZG 20141112

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
$mail->addAttachment('1111.png');         // 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;
} else {
    echo 'Message has been sent';
}

mail by HZG.rar

205.42 KB, 下载次数: 1558

PHPMailer-master.zip

209.93 KB, 下载次数: 1567

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-19 00:29 , Processed in 0.037863 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表