• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php发送网页邮件的格式(服务器是unix),该怎么解决

php 搞代码 4年前 (2022-01-25) 31次浏览 已收录 0个评论

php发送网页邮件的格式(服务器是unix)
因为服务器事unix的所以用mail函数就可以发邮件,我现在要作的就是像中华英才一样给客户发送简历带有格式那种~~~~

——解决方案——————–
什么动态呢,你是指那个message那里面的信息是动态的吗,这个很容易啊!
你这里插入一些PHP的表单变量(用户端输入的表单数据),不就可以了吗
——解决方案——————–
看phpmail类的例子
—-本文来源gao@daima#com搞(%代@#码@网&搞gaodaima代码–解决方案——————–

设定邮件的头信息中的content-type
Content-Type: text/html; charset=”你自己的编码”

从mail的第4个参数设定。
lz参考一下文档,有例子
http://jp.php.net/manual/en/function.mail.php
——解决方案——————–
<?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\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))


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php发送网页邮件的格式(服务器是unix),该怎么解决

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址