<?
1 include "sendmail.class.php3";
2 $email="hello, this is a test letter!";
3 $sendmail=new send_mail("smtp.263.net", "limodou", true); //顯示調示信息
4 if($sendmail->send("[email protected]", "[email protected]", "test", $email))
5 {
6 echo "發送成功!<br>";
7 }
8 else
9 {
10 echo "發送失??!<br>";
11 }
?>
--------------------------------------------------------------------------------
第1行,裝入send_mail類。
第3行,創建一個類的實例,且設置顯示調示信息,如果不想顯示,可以
$sendmail=new send_mail("smtp.263.net");。
第4行,發送郵件。
很簡單,不是嗎?下面再給合以前的發送mime郵件的例子,給出一個發送html附件的例子。
--------------------------------------------------------------------------------
<?php
include "mime.class.php3";
//注,在發送mime郵件一文中,這個類文件名為mime.class,在此處我改成這樣的
$to = '[email protected]'; //改為收信人的郵箱
$str = "newsletter for ".date('m y', time());
//信息被我改少了
$html_data = '<html><head><title>'. $str. '</title></head>
<body bgcolor="#ffffff">
hello! this is a test!
</body>
</html>';
//生成mime類實例
$mime = new mime_mail("[email protected]", $to, $str);
//添加html附件
$mime->attach($html_data, "", html, base64);
//注釋掉,采用我的發送郵件處理
//$mime->send_mail();
//生成郵件
$mime->gen_email();
//顯示郵件信息
//echo $mime->email."<br>";
//包含sendmail文件
include "sendmail.class.php3";
//創建實例
$sendmail=new send_mail("smtp.263.net", "limodou", true);
//發送郵件
$sendmail->send("[email protected]", "[email protected]", $str, $mime->email);
?>
新聞熱點
疑難解答