后端开发|php教程
quot,this,gt,header,smtp
后端开发-php教程
关于PHP提交表单自动发送邮件问题。
最近做的一个网站,要实现一个功能就是提交表单自动发送表单内容到指定邮箱。因为对PHP比较陌生,但网站后台的CMS是PHP,所以只好硬着头皮来了。在网上找了段比较流行的代码。然后我现在的问题就是这段PHP代码如何与表单连接。我现在把代码贴出来请大家帮帮我。
flash整站源码,win 如何与ubuntu,Tomcat启动后内存涨,python爬虫动漫,php怎么查找文字,十堰工程机械seo推广哪个好lzw
<?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;
诗词大全源码,vscode可以写javaee,ubuntu窗口调整,ps 没有tomcat,采用SQlite数据库原因,爬虫内容如何以jaon形式存储,php调用jar,北京seo营销哪家好,建材企业网站模板,超炫网页设计,怎么替换dede模板lzw
/* Private Variables */
var $sock;
webapp源码下载,vscode不能自动补全怎么办,ubuntu 重置系统,tomcat线程数与cpu核,检索数据sqlite,网页设计的素材图片素材,服务器屏蔽ip段,百度图文新闻插件代码,python前端框架图片,体制内的爬虫,PHP arsort,新网站seo怎么优化,html网站开场动画效果模板,网页制作特效代码html,仿苹果官网模板,boostrap手机页面布局,项目api管理系统,聊天小程序代码lzw
/* 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 =””;
$this->sock = FALSE;
}
/* Main Function */
function sendmail($to, $from, $subject = “”, $body = “”, $mailtype, $cc = “”, $bcc = “”, $additional_headers = “”)
{
$header=””;
$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\r\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());
$header .= “Message-ID: \r\n”;
$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)));
}
$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)) {
$this->log_write(“E-mail has been sent to \n”);
} else {
$this->log_write(“Error: Cannot send email to \n”);
$sent = FALSE;
}
fclose($this->sock);
$this->log_write(“Disconnected from remote host\n”);
}
echo “
“;
echo $header;
return $sent;
}
/* Private Functions */
function smtp_send($helo, $from, $to, $header, $body = “”)
{
if (!$this->smtp_putcmd(“HELO”, $helo)) {
return $this->smtp_error(“sending HELO command”);
}
#auth
if($this->auth){
if (!$this->smtp_putcmd(“AUTH LOGIN”, base64_encode($this->user))) {
return $this->smtp_error(“sending HELO command”);
}
if (!$this->smtp_putcmd(“”, base64_encode($this->pass))) {
return $this->smtp_error(“sending HELO command”);
}
}
#
if (!$this->smtp_putcmd(“MAIL”, “from:”)) {
return $this->smtp_error(“sending MAIL from command”);