php發送網頁郵件的格式(伺服器是unix),該怎麼解決
最後更新:2016-06-13
來源:互聯網
上載者:User
php發送網頁郵件的格式(伺服器是unix)
因為伺服器事unix的所以用mail函數就可以發郵件,我現在要作的就是像中華英才一樣給客戶發送簡曆帶有格式那種~~~~
------解決方案--------------------
什麼動態呢,你是指那個message那裡面的資訊是動態嗎,這個很容易啊!
你這裡插入一些PHP的表單變數(使用者端輸入的表單資料),不就可以了嗎
------解決方案--------------------
看phpmail類的例子
------解決方案--------------------
設定郵件的頭資訊中的content-type
Content-Type: text/html; charset="你自己的編碼"
從mail的第4個參數設定。
lz參考一下文檔,有例子
http://jp.php.net/manual/en/function.mail.php
------解決方案--------------------
class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;
/* Private Variables */
var $sock;
/* Constractor */
function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
$this->debug = FALSE;
$this->smtp_port = $smtp_port;
$this->relay_host = $relay_host;
$this->time_out = 30; //is used in fsockopen()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; //is used in HELO command
$this->log_file = "error.txt";
$this->sock = FALSE;
}
/* Main Function */
function sendmail($to, $from, $subject , $body, $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($from));
$body = ereg_replace("(^|(\r\n))(\.)", "\1.\3", $body);
$header= "MIME-Version:1.0\r\n";
if($mailtype=="HTML")
{
$header .= "Content-Type:text/html;charset=utf-8\r\n";
//$header .= "Content-Transfer-Encoding: base64\n\n";
}
$header .= "To: ".$to."\r\n";
if ($cc != "")
{
$header .= "Cc: ".$cc."\r\n";
}
$header .= "From: $from<".$from.">\r\n";
$header .= "Subject: ".$subject."\r\n";
$header .= $additional_headers;
$header .= "Date: ".date("r")."\r\n";
$header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
list($msec, $sec) = explode(" ", microtime());
$TO = explode(",", $this->strip_comment($to));
if ($cc != "")
{
$TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
}
if ($bcc != "")
{
$TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
}
$this->Headers = $header;
$sent = TRUE;
foreach ($TO as $rcpt_to)
{
$rcpt_to = $this->get_address($rcpt_to);
if (!$this->smtp_sockopen($rcpt_to))
{
$this->log_write("Error: Cannot send email to ".$rcpt_to."\n");
$sent = FALSE;
continue;
}
if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body))