您好,欢迎访问一九零五行业门户网

关于PHP提交表单自动发送邮件有关问题

关于php提交表单自动发送邮件问题。
最近做的一个网站,要实现一个功能就是提交表单自动发送表单内容到指定邮箱。因为对php比较陌生,但网站后台的cms是php,所以只好硬着头皮来了。在网上找了段比较流行的代码。然后我现在的问题就是这段php代码如何与表单连接。我现在把代码贴出来请大家帮帮我。
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);
其它类似信息

推荐信息