详细讲解php的jmai组件及发送邮件实例

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 = “”) { $mail_from = $this->get_address($this->strip_comment($from)); $body = ereg_replace(“(^|(
))(.)”, “1.3”, $body); $header = “mime-version:1.0
“; if($mailtype==”html”){ $header .= “content-type:text/html
“; } $header .= “to: “.$to.”
“; if ($cc != “”) { $header .= “cc: “.$cc.”
“; } $header .= “from: $from
“; $header .= “subject: “.$subject.”
“; $header .= $additional_headers; $header .= “date: “.date(“r”).”
“; $header .= “x-mailer:by redhat (php/”.phpversion().”)
“; list($msec, $sec) = explode(” “, microtime()); $header .= “message-id:
“; $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.”
“); $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
“); } else { $this->log_write(“error: cannot send email to
“); $sent = false; } fclose($this->sock); $this->log_write(“disconnected from remote host
“); &n

http://www.bkjia.com/phpjc/509200.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/509200.htmltecharticle% on error resume next dim jmail, contentid set jmail = server.createobject(“jmail.message”) jmail.charset = “gb2312″ 邮件字符集,默认为”us-ascii” jmail.isoencodeheaders =…

Posted in 未分类