phpmailer使用

phpmailer的属性和方法,来自网络

 

A开头:

        $AltBody --属性

         出自:PHPMailer::$AltBody ,文件:class.phpmailer.php

         说明:该属性的设置是在邮件正文不支持HTML的备用显示

        AddAddress --方法

         出自:PHPMailer::AddAddress(),文件:class.phpmailer.php

         说明:增加收件人。参数1为收件人邮箱,参数2为收件人称呼。例AddAddress("xiaoxiaoxiaoyu@xiaoxiaoyu.cn","xiaoxiaoyu"),但参数2可选,AddAddress(xiaoxiaoxiaoyu@xiaoxiaoyu.cn)也是可以的。函数原型:

         public function AddAddress($address, $name = '') {}

        AddAttachment--方法

         出自:PHPMailer::AddAttachment(),文件:class.phpmailer.php

         说明:增加附件。参数:路径,名称,编码,类型。其中,路径为必选,其他为可选

         函数原型:

         AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream'){}

        AddBCC --方法

          出自:PHPMailer::AddBCC(),文件:class.phpmailer.php

         说明:增加一个密送。抄送和密送的区别请看[SMTP发件中的密送和抄送的区别] 。参数1为地址,参数2为名称。注意此方法只支持在win32下使用SMTP,不支持mail函数

         函数原型:

         public function AddBCC($address, $name = ''){}

        AddCC --方法

         出自:PHPMailer::AddCC(),文件:class.phpmailer.php

         说明:增加一个抄送。抄送和密送的区别请看[SMTP发件中的密送和抄送的区别] 。参数1为地址,参数2为名称注意此方法只支持在win32下使用SMTP,不支持mail函数

         函数原型:

         public function AddCC($address, $name = '') {}

        AddCustomHeader --方法

          出自:PHPMailer::AddCustomHeader(),文件:class.phpmailer.php

         说明:增加一个自定义的E-mail头部。参数为头部信息

         函数原型:

         public function AddCustomHeader($custom_header){}

        AddEmbeddedImage --方法

         出自:PHPMailer::AddEmbeddedImage(),文件:class.phpmailer.php

         说明:增加一个嵌入式图片。参数:路径,返回句柄[,名称,编码,类型]

         函数原型:

          public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {}

         提示: AddEmbeddedImage(PICTURE_PATH. "index_01.jpg ", "img_01 ", "index_01.jpg ");
         在html中引用<img src= "cid:img_01 ">

        AddReplyTo --方法

         出自:PHPMailer:: AddReplyTo(),文件:class.phpmailer.php

         说明:增加回复标签,如"Reply-to"。参数1地址,参数2名称

         函数原型:

          public function AddReplyTo($address, $name = '') {}

        AddStringAttachment -方法

          出自:PHPMailer:: AddStringAttachment(),文件:class.phpmailer.php

         说明;增加一个字符串或二进制附件(Adds a string or binary attachment (non-filesystem) to the list.?)参数:字符串,文件名[,编码,类型]

         函数原型:

         public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {}

        Authenticate --方法

         出自:SMTP::Authenticate(),文件:class.smtp.php

         说明:开始SMTP认证,必须在Hello()之后调用,如果认证成功,返回true,参数1用户名,参数2密码

         函数原型:

         public function Authenticate($username, $password) {}

B开头

        $Body --属性

         出自:PHPMailer::$Body 文件: class.phpmailer.php

         说明:邮件内容,HTML或Text格式

C开头

        $CharSet --属性

         出自:PHPMailer::$CharSet 文件:class.phpmailer.php

         说明:邮件编码,默认为iso-8859-1

        $ConfirmReadingTo --属性

         出自:PHPMailer::$ConfirmReadingTo 文件class.phpmailer.php

         说明:回执?

        $ContentType --属性

         出自:PHPMailer::$ContentType 文件: class.phpmailer.php

         说明:文档的类型,默认为"text/plain"

        $CRLF --属性

         出自:PHPMailer::$ContentType 文件:class.phpmailer.php

         说明:SMTP回复结束的分隔符(SMTP reply line ending?)

        class.phpmailer.php --对象

         出自:class.phpmailer.php 文件: class.phpmailer.php

         说明:phpmailer对象

        class.smtp.php --对象

         出自:class.smtp.php 文件: class.smtp.php

         说明:SMTP功能的对象

        ClearAddresses --方法

         出自:PHPMailer::ClearAddresses() 文件: class.phpmailer.php

         说明:清除收件人,为下一次发件做准备。返回类型是void

        ClearAllRecipients --方法

         出自:PHPMailer::ClearAllRecipients() 文件: class.phpmailer.php

         说明:清除所有收件人,包括CC(抄送)和BCC(密送)

        ClearAttachments --方法

         出自:PHPMailer::ClearAttachments() 文件: class.phpmailer.php

         说明:清楚附件

        ClearBCCs --方法

         出自:PHPMailer::ClearBCCs() 文件 class.phpmailer.php

         说明:清楚BCC (密送)

        ClearCustomHeaders --方法

         出自:PHPMailer::ClearCustomHeaders() 文件: class.phpmailer.php

         说明:清楚自定义头部

        ClearReplyTos --方法

         出自:PHPMailer::ClearReplyTos() 文件: class.phpmailer.php

         说明:清楚回复人

        Close --方法

         出自:SMTP::Close() 文件: class.smtp.php

         说明:关闭一个SMTP连接

        Connect --方法

         出自:SMTP::Connect() 文件: class.smtp.php

         说明:建立一个SMTP连接

 

 今天用phpmailer,举报房源,其实我已经有一个比较好用的而且简单的发邮件类,为了体验一下phpmailer,果然好用

code:这里前端用jquery ajax提交的,这只是后面处理文件

 

<?php
	header("content-type:text/plain; charset=gb2312");
	include_once 'model/class.phpmailer.php';
	if(is_array($_POST)){
		$buildName=iconv('utf-8','gb2312',$_POST['buildName']);
		$name=iconv('utf-8','gb2312',$_POST['name']);
		$content=iconv('utf-8','gb2312',$_POST['content']);
		$tel=iconv('utf-8','gb2312',$_POST['tel']);
		$fileName=iconv('utf-8','gb2312',$_POST['myFileName']);
	}
	$title="网友:{$name}举报楼盘:{$buildName}";
	$content="网友:{$name}<br />举报楼盘:{$buildName}<br />举报人电话:{$tel}<br />举报内容:{$content}<br />此房源的详细链接为:<a href=\"{$fileName}\" >{$buildName}</a>";
	$mail=new PHPMailer();
	$address='service@sfdsfsd.comf';
	$mail->IsSMTP();
	$mail->Host='smtp.163.com';
	$mail->CharSet='gb2312';
	$mail->SMTPAuth=true;
	$mail->Username='sfdsfsdf@163.com';
	$mail->Password='sjfldfjlsdjf';
	$mail->Port=25;
	$mail->From='services0551@163.com';
	$mail->FromName=$name;
	$mail->AddAddress($address,'0551房产网');
	$mail->IsHTML(true);
	$mail->Subject=$title;
	$mail->Body=$content;
	if(!$mail->Send()){
		echo "邮件发送失败";
		exit;
	}else{
		echo "邮件发送成功";
	}
?>

 在使用的过程中,遇到两点:要包含class.smtp.php,其次,要设置编码,默认为:iso-8859-1,$mail->CharSet='gb2312';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值