我尝试使用php mail()
发送邮件,但它没有显示任何错误或已在gmail中收到错误。我在服务器上运行此代码:
<?php
// Multiple recipients
$to = 'ram@gmail.com'; // note the comma
// Subject
$subject = 'Birthday Reminders for August';
// Message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Johny</td><td>10th</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>';
// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
// Additional headers
$headers[] = 'To: ram <ram@gmail.com>';
$headers[] = 'From: Birthday Reminder <admin@example.com>';
echo $message;
// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));
?>
使用上面的代码将邮件发送到gmail但是在运行文件后我无法看到任何错误,也没有在gmail中收到邮件。我在服务器上运行的代码不在localhost中。