【www.gdgbn.com--邮件】

 代码如下

require("class.phpmailer.php");
$mail = new phpmailer();
$mail->charset="utf-8";
$address = $_post["address"];
$mail->issmtp();                                      // set mailer to use smtp
$mail->host = "mail.xxx.com";  // specify main and backup server
$mail->smtpauth = true;     // turn on smtp authentication
$mail->username = "phpmailer@xxx.com";  // smtp username
$mail->password = "******"; // smtp password

$mail->from = "这里应该可以填写你想要填写的邮箱";
$mail->fromname = "这里是要显示的名称";
$mail->addaddress("$address", "");
//$mail->addaddress("");                  // name is optional
//$mail->addreplyto("", "");

//$mail->wordwrap = 50;                                 // set word wrap to 50 characters
//$mail->addattachment("/var/tmp/file.tar.gz");         // add p_w_uploads
//$mail->addattachment("/tmp/image.jpg", "new.jpg");    // optional name
//$mail->ishtml(true);                                  // set email format to html

$mail->subject = "phpmailer测试邮件";
$mail->body    = "hello,这是松子的测试邮件";
$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;
}

echo "message has been sent";

/*
$altbody --属性
出自:phpmailer ::$altbody
文件:class.phpmailer .php
说明:该属性的设置是在邮件正文不支持html的备用显示

addaddress --方法
出自:phpmailer ::addaddress(),文件:class.phpmailer .php
说明:增加收件人。参数1为收件人邮箱,参数2为收件人称呼。例addaddress("to@163.com","to name"),但参数2可选,addaddress(to@163.com )也是可以的。
函数原型: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中引用

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连接mailer.html

$contenttype --属性
出自:phpmailer ::$contenttype
文件: class.phpmailer .php
说明:文档的类型,默认为"text/plain"

d开头
$do_debug --属性
出自:smtp::$do_debug
文件:class.smtp.php
说明:smtp调试输出

data -方法
出自:smtp::data()
文件:class.smtp.php
说明:向服务器发送一个数据命令和消息信息(sendsthemsg_datatotheserver)

e开头

$encoding --属性
出自:phpmailer ::$encoding
文件:class.phpmailer .php
说明:设置邮件的编码方式,可选:"8bit","7bit","binary","base64",和"quoted-printable".

$errorinfo --属性
出自:phpmailer ::$errorinfo
文件:class.phpmailer .php
说明:返回邮件smtp中的最后一个错误信息


expand --方法
出自:smtp::expand()
文件:class.smtp.php
说明:返回邮件列表中所有用户。成功则返回数组,否则返回 false(expandtakesthenameandaskstheservertolistallthepeoplewhoaremembersofthe_list_.expandwillreturnbackandarrayoftheresultorfalseifanerroroccurs.)

f开头:

$from --属性
出自:phpmailer ::$from文件class.phpmailer .php
说明:发件人e-mail地址
$fromname --属性
出自:phpmailer ::$fromname
文件:class.phpmailer .php
说明:发件人称呼

h开头:

$helo --属性
出自:phpmailer ::$helo
文件:class.phpmailer .php
说明:设置smtphelo,默认是$hostname(setsthesmtpheloofthemessage(defaultis$hostname).)

$host --属性
出自:phpmailer ::$host
文件:class.phpmailer .php
说明:设置smtp服务器,格式为:主机名[端口号],如smtp1.example.com:25和smtp2.example.com都是合法的

$hostname --属性
出自:phpmailer ::$hostname
文件:class.phpmailer .php
说明:设置在message-id和andreceivedheaders中的hostname并同时被$helo使用。如果为空,默认为server_name或"localhost.localdomain"

hello --方法
出自:smtp::hello()
文件:class.smtp.php
说明:向smtp服务器发送helo命令

help --方法
出自:smtp::help()
文件:class.smtp.php
说明:如果有关键词,得到关键词的帮助信息

i开头:

iserror --方法
出自:phpmailer ::iserror()
文件:class.phpmailer .php
说明:返回是否有错误发生

ishtml --方法
出自:phpmailer ::ishtml()
文件:class.phpmailer .php
说明:设置信件是否是html格式

ismail --方法
出自:phpmailer ::ismail()
文件:class.phpmailer .php
说明:设置是否使用php的mail函数发件

isqmail --方法
出自:phpmailer ::isqmail()
文件:class.phpmailer .php
说明:设置是否使用qmailmta来发件

issendmail-- 方法
出自:phpmailer ::issendmail()
文件:class.phpmailer .php
说明:是否使用$sendmail程序来发件

issmtp--方法
出自:phpmailer ::issmtp()
文件:class.phpmailer .php
说明:是否使用smtp来发件

m开头:

$mailer --属性
出自:phpmailer ::$mailer
文件:class.phpmailer .php
说明:发件方式,("mail","sendmail",or"smtp").中的一个

mail --方法
出自:smtp::mail()
文件:class.smtp.php
说明:从$from中一个邮件地址开始处理,返回true或false。如果是true,则开始发件

n开头:

noop-- 方法
出自:smtp::noop()
文件:class.smtp.php
说明:向smtp服务器发送一个noop命令

p开头:
$password --属性
出自:phpmailer ::$password
文件:class.phpmailer .php
说明:设置smtp的密码

$plugindir --属性
出自:phpmailer ::$plugindir
文件:class.phpmailer .php
说明:设置phpmailer 的插件目录,仅在smtpclass不在phpmailer 目录下有效

$port --属性
出自:phpmailer ::$port
文件:class.phpmailer .php
说明:设置smtp的端口号

$priority --属性
出自:phpmailer ::$priority
文件:class.phpmailer .php
说明:设置邮件投递优先等级。1=紧急,3=普通,5=不急

phpmailer --对象
出自:phpmailer
文件:class.phpmailer .php
说明:phpmailer -phpemailtransportclass

q开头

quit --方法
出自:smtp::quit()
文件:class.smtp.php
说明:向服务器发送quit命令,如果没有错误发生。那么关闭sock,不然$close_on_error为true

r开头

recipient --方法
出自:smtp::recipient()
文件:class.smtp.php
说明:使用to向smtp发送rcpt命令,参数为:$to

reset --方法
出自:smtp::reset()
文件:class.smtp.php
说明:发送rset命令从而取消处理中传输。成功则返回true,否则为false

s开头:

$sender --属性
出自:phpmailer ::$sender
文件:class.phpmailer .php
说明:setsthesenderemail(return-path)ofthemessage.ifnotempty,willbesentvia-ftosendmailoras"mailfrom"insmtpmode.

$sendmail --属性
出自:phpmailer ::$sendmail
文件:class.phpmailer .php
说明:设置发件程序的目录

$smtpauth --属性
出自:phpmailer ::$smtpauth
文件:class.phpmailer .php
说明:设置smtp是否需要认证,使用username和password变量

$smtpdebug --属性
出自:phpmailer ::$smtpdebug
文件:class.phpmailer .php
说明:设置smtp是否调试输出?

$smtpkeepalive --属性
出自:phpmailer ::$smtpkeepalive
文件:class.phpmailer .php
说明:在每次发件后不关闭连接。如果为true,则,必须使用smtpclose()来关闭连接

$smtp_port --属性
出自:smtp::$smtp_port
文件:class.smtp.php
说明:设置smtp端口

$subject --属性
出自:phpmailer ::$subject
文件:class.phpmailer .php
说明:设置信件的主题

send --方法
出自:smtp::send()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

send --方法
出自:phpmailer ::send()
文件:class.phpmailer .php
说明:创建邮件并制定发件程序。如果发件不成功,则返回false,请使用errorinfo来查看错误信息

sendandmail --方法
出自:smtp::sendandmail()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

sendormail --方法
出自:smtp::sendormail()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

setlanguage --方法
出自:phpmailer ::setlanguage()
文件:class.phpmailer .php
说明:设置phpmailer 错误信息的语言类型,如果无法加载语言文件,则返回false,默认为english

smtp --方法
出自:smtp::smtp()
文件:class.smtp.php
说明:初始化一个对象以便数据处于一个已知的状态

smtp --对象
出自:smtp
文件:class.smtp.php
说明:smtp对象

smtpclose --方法
出自:phpmailer ::smtpclose()
文件:class.phpmailer .php
说明:如果有活动的smtp则关闭它。

t开头

$timeout --属性
出自:phpmailer ::$timeout
文件:class.phpmailer .php
说明:设置smtp服务器的超时(单位:秒)。注意:在win32下,该属性无效

turn --方法
出自:smtp::turn()
文件:class.smtp.php
说明:这是一个可选的smtp参数,目前phpmailer 并不支持他,可能未来支持

u开头

$username --属性
出自:phpmailer ::$username
文件:class.phpmailer .php
说明:设置smtp用户名

v开头

$version --属性
出自:phpmailer ::$version
文件:class.phpmailer .php
说明:返回phpmailer 的版本

verify --方法
出自:smtp::verify()
文件:class.smtp.php
说明:通过服务器检查用户名是否经过验证

w开头:

$wordwrap --属性
出自:phpmailer ::$wordwrap
文件:class.phpmailer .php
说明:设置每行最大字符数,超过改数后自动换行

*/
?>

本文来源:http://www.gdgbn.com/jsp/27053/