我正在开发一个Web应用程序,并且在某些时候我需要发送确认邮件。 Sendmail在安装,但是当我尝试运行这个代码时,它加载页面非常慢,没有任何反应。在Ubuntu上无法使用Php mail()14.04
<?php
$to = "[email protected]";
$subject = "Confimation";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <[email protected]>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
这是mail.log
May 19 13:18:02 al-Inspiron-5548 sendmail[6934]: t4JBI24R006934: from=www-data, size=416, class=0, nrcpts=0, msgid=<[email protected]>, [email protected]
May 19 13:18:02 al-Inspiron-5548 sendmail[6936]: t4JBI2ex006936: from=www-data, size=416, class=0, nrcpts=0, msgid=<[email protected]>, [email protected]
有人能帮助我吗?
这是一台本地计算机吗?我想是因为电脑的名字。大多不可能从家庭网络发送电子邮件。 – Richard
如果您的sendmail设置有效,并且您的防火墙允许端口25出站,那么几乎可以肯定的是您的问题在于gmail将此电子邮件视为垃圾邮件 –
查看您的中继,您的邮件服务器在本地安装,与公众无关在端口25上的IP,您需要使用公共IP从您的计算机发送邮件。 –