我正在尝试使用 Gmail 作为服务器发送邮件。永远不会发送电子邮件,也不会给出确认或错误消息。Mail、Net_SMTP 和 Net_Socket pear 软件包已安装。我设置了代理,可以通过cmd连接到互联网。“发送”之后的回显从未出现,但之前的回显出现,这意味着连接状态为空。谁能看到我缺少/误解的内容?
php:
if (isset($_POST['submit'])){
error_reporting(0);
$human = $_POST['human'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'toreceive@gmail.com';
$body = "$message";
$header = array (
'From' => 'tosend@gmail.com',
'Subject' => 'Hello'
);
$smtp = Mail::factory('smtp', array(
'auth' => true,
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'username' => 'username@gmail.com',
'password' => 'password',
'charset' => 'iso-8859-1'
));
if (connection_status == 0)
echo "<script type='text/javascript'>alert('Before Mail');</script>";
$mail = $smtp->send($to, $header, $body);
echo "<script type='text/javascript'>alert('After Mail');</script>";
if (@PEAR::isError($mail))
echo("<p>" . $mail->getMessage() . "</p>");
else
echo("<p>Message successfully sent!</p>");
}
?>
相关的php.ini:
[mail function]
SMTP = localhost
smtp_port = 25
extension=php_openssl.dll
extension=php_sockets.dll