使用 phpMailer 基于(SMTP) 发送邮件
2014-08-05 20:52
666 查看
PHPMailer是一个用于发送电子邮件的PHP函数包。它提供的功能包括:在发送邮时指定多个收件人,抄送地址,暗送地址和回复地址、支持多种邮件编码包括:8bit,base64,binary和quoted-printable、支持SMTP验证、支持带附件的邮件和Html格式的邮件。
实现代码 :
实现代码 :
<?php include 'class.smtp.php'; include 'class.phpmailer.php'; $mail = new PHPMailer; $mail->isSMTP(); // 开启SMTP服务 $mail->Host = 'smtp.xx.com'; // SMTP 服务器地址 各大邮箱都可以使用SMTP 并有详细说明 $mail->SMTP_PORT = 25; // SMTP 服务端口 默认为25 $mail->SMTPAuth = true; // 开启SMTP认证 $mail->Username = 'xx@xx.com'; // 邮箱账号 $mail->Password = '......'; // 邮箱密码 $mail->From = 'xx@xx.com'; //发件箱 应该和 用户名一致 $mail->FromName = 'Mailer'; //发件人称呼 $mail->addAddress('xxx@xxx.com', '称呼'); // 收件人地址及称呼 $mail->WordWrap = 50; //增加附件 如果有请在此设置 //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); $mail->isHTML(true); // 使用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'; } ?>
相关文章推荐
- Wordpress无法发送邮件,基于插件“Contact Form 7”,修改class-phpmailer.php使用SMTP解决。
- 基于php5.5使用PHPMailer-5.2发送邮件
- ThinkPHP_phpmailer使用外部认证SMTP发送邮件
- 在CI中集成phpmailer,方便使用SMTP发送邮件
- 使用PHPmailer 发送邮件,使用QQ smtp服务器
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在.NET中使用SMTP发送邮件
- ASP使用CDO.Message+SMTP发送邮件
- *使用C# 创建邮件发送组件(SMTP)
- 使用TNMSMTP控件在需认证服务器上发送邮件
- 在VB6.0中使用Socket发送带SMTP认证的邮件
- .NET 1.1 下不使用 System.Web.Mail.SmtpMail 发送邮件的其它选择
- .NET 1.1 下不使用 System.Web.Mail.SmtpMail 发送邮件的其它选择
- 使用System.Net.Mail.SmtpClient发送邮件时出现的乱码问题
- 在VB6.0中使用Socket发送带SMTP认证的邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 使用javamail发送SMTP验证邮件
- 在.NET中使用SMTP发送邮件
- 使用OpenSMTP.NET在线发送邮件
- 在VB6.0中使用Socket发送带SMTP认证的邮件