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

PHP 使用 SMTP 发送邮件(PEAR)

phper 多数使用 mail 函数来发送邮件,但我们可以使用其他的 smtp 服务器来发送,这里推荐使用 pear’s mail package 来发送邮件。 $subject = this mail is sent from smtp.;$mail_body = this is the body of the mail which is sent using smtp.;$from = from: from name ; $to = to: to name ; $receiver = toaddress@xpertdeveloper.com; // setting up the headers$headers[from] = $from; $headers[to] = $to; $headers[subject] = $subject; $headers[reply-to] = reply@address.com; $headers[content-type] = text/plain; charset=iso-2022-jp; $headers[return-path] = returnpath@address.com; // setting up the smtp setting$smtp_info[host] = smtp.server.com; $smtp_info[port] = 25; $smtp_info[auth] = true; $smtp_info[username] = smtp_user; $smtp_info[password] = smtp_password; // creating the pear mail object :$mail_obj =& mail::factory(smtp, $smtp_info); // sending the mail now$mail_sent = $mail_obj->send($receiver, $headers, $mail_body); // if any error the see for that here:if (pear::iserror($mail_sent)) { print($mail_sent->getmessage());}
复制代码
其它类似信息

推荐信息