<?
class Jmail
{
public $Username; //郵局用戶名
public $Password; //密碼
public $FormName ; //發件人姓名
public $From ; //發件人地址
public $Addrecipient ; //收件人地址
public $Ttile ; //郵件標題
public $Content; //郵件內容
public $Smtp; //郵件服務器
function Send(){
$Jmail = new com("Jmail.Message"); //實例化壹個Jmail對象
$Jmail->SiLent=true; //設置成True的話Jmail不會提示錯誤只會返回True和False
$Jmail->LogGing = false; //是否開啟日誌
$Jmail->CharSet = "GB2312"; //設定字符串編碼
$Jmail->ContentType = "Text/html"; //郵件的格式為HTML格式
$Jmail->MailServerUsername = $this->Username; //發信箱用戶名
$Jmail->MailServerPassword = $this->Password; //發信箱密碼
$Jmail->FromName = $this->FromName; //發件人姓名
$Jmail->From = $this->From; //發件人地址
$Jmail->AddRecipient($this->Addrecipient); //收件人地址
$Jmail->Subject = $this->Title;//Email標題
$Jmail->Body = $this->Content; //Email正文
$JmailError = $Jmail->Send($this->Smtp); //Smtp服務器
if($JmailError){ //判斷郵件是否發送成功
return true;
}else{
return false;
}
}
}
//這裏是調用代碼
$jmail = new Jmail();
$jmail->Username = "lwf0757";
$jmail->Password = "0757";
$jmail->FromName = "梁";
$jmail->From = "lwf0757@163.com";
$jmail->Addrecipient = "313120799@qq.com";
$jmail->Title = "這是標題";
$jmail->Content = $_POST["contact_message"]; //"這是內容";
$jmail->Smtp = "smtp.163.com";
if($jmail->Send()){
echo "成功哦!";
}else{
echo "失敗哦!";
}
>