我已经做了一个HTML电子邮件,一切工作到目前为止。我打算用PHP发送它(使用mail();函数)。但是,当我这样做时,邮件没有到达hotmail和Gmail帐户。我搜索了一下,有人建议使用PHPmailer。有人可以帮我用phpmailer吗?
我下载了PHPmailer并将其安装在我的服务器上。到现在为止还挺好。但现在我有以下代码:
<?php
set_include_path('.:c:\domains\mydomain\wwwroot\phpmailer\phpmailer.inc.php');
set_include_path('.:c:\domains\mydomain\wwwroot\phpmailer\smtp.inc.php');
require("phpmailer.inc.php");
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->From = "[email protected]";
$mail->AddAddress("[email protected]");
$mail->Subject = "An HTML Message";
$mail->Body = "Hello, <b>my friend</b>! \n\n This message uses HTML entities!";
if($mail->Send()) {
echo 'Message is sent';
} else {
echo 'Message was not sent..';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
?>
我有几个问题:
- 输出告诉我的邮件没有发送,但它是。
- 我得到两个主题
- 如果我添加更多的HTML(如表),它仍然被拒绝hotmail(也可能是gmail)。
此外,我看到有一个SMTP功能。如何使用这个功能?我是否需要写下我自己的SMTP?
如果有人能帮助我,会很开心!
编辑:
class SMTP {
var $SMTP_PORT = 25; # the default SMTP PORT
var $CRLF = "\r\n"; # CRLF pair
var $smtp_conn; # the socket to the server
var $error; # error if any on the last call
var $helo_rply; # the reply the server sent to us for HELO
var $do_debug; # the level of debug to perform
/*
* SMTP()
*
* Initialize the class so that the data is in a known state.
*/
function SMTP() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
}
通过服务器你的意思是'远程server'? 你的set_inclide_path包含本地服务器路径?和PHPMailer将无法在您的本地服务器上工作 –
Nah,服务器我的意思是我的网站。对不起 – Frank