以前的mail(),lzllr已經不在流行,所以放上最近用的例項,留做回憶。
複製** **如下:
php
require_once(dirname(__file__)."/../phpmailer/class.phpmailer.php");
//包含class.phpmailer.php
/**
* @param string $send_to_mail 目標郵件
* @param stinrg $subject 主題
* @param string $body 郵件內容
* @param string $extra_hdrs 附加資訊
* @param string $username 收件人
* @param string $replyname 回覆人
* @param string $replymail 回覆位址
* @return array(bealoon,string) 返回陣列包括兩個元素,bealoon表示是否成功,string為提示資訊
*/ function sendmail($send_to_mail,$subject,$body,$extra_hdrs,$username,$replyname="reply",$replymail="[email protected]")else!");
return $results;
} }
$send_mail=sendmail($to,$subject,$content,$headers,$name);
if($send_mail["result"])else
exit();
?>
複製** **如下:
<?php
include ('class/class.phpmailer.php');
$config = array(
'host'=>'smtp.163.com',
'port'=>'25',
'user'=>'***',
'passwd'=>'****',
'from'=>'[email protected]',
'fromname'=>'鄭州',
); $subject = 'this is a test mail';
$body = '測試內容這是內容';
$address='[email protected]';
$username='本人';
$mail = new php
$mail->charset = 'gb2312';
$mail->issmtp();
$mail->host = $config['host'];
$mail->port = $config['port'];
$mail->from = $config['from'];
$mail->fromname = $config['fromname'];
$mail->smtpauth = true;
$mail->username = $config['user'];
$mail->password = $config['passwd'];
$mail->subject=$subject;
$mail->altbody="text/html";
$mail->msghtml($body);
$mail->addaddress($address,$username);
if(!$mail->send())
else
本文標題: 使用 phpmailer 傳送郵件例項應用
本文位址:
使用phpmailer傳送郵件
說起來還真不好意思.弄個郵件左左右右差不多弄了2周,當然了,我請了一周的假期.我們公司的郵件發不出去了,原來的郵件是用的php自帶的mail 函式.可能是配置問題吧.這個不是我要處理的問題,暫且不去找原因了,解決辦法,就是用乙個smtp 發郵件的外掛程式,來處理,要傳送的內容,主題都不用改動 解壓後...
使用phpmailer傳送郵件
解壓後有2個php檔案 2個類 1個html檔案 api 將2個php檔案放到php專案中 簡述 我這裡是用乙個163的郵箱發訊息給126的郵箱 關鍵 如下 require class.phpmailer.php mail new phpmailer true 建立郵件傳送類 mail charse...
使用phpmailer傳送郵件
最近做郵件傳送的時候嘗試了一下phpmailer,但是在用的過程中還是遇到一些問題,在這裡記一下。做的過程中主要遇到這幾個問題。1.在做常規測試的時候,發現郵件傳送特別慢。這裡主要找到是這句造成的 this smtp conn stream socket client host port,errno...