if (@mail('email@gmail.com', 'Email Works', '$text')))
{
echo('<p>Mail sent successfully.</p>');
}
else
{
echo('<p>Mail could not be sent.</p>');
}
打印"邮件发送成功"消息,但我没有收到电子邮件
您的电子邮件内容将是字面上的$text与该代码。
试
if (mail('email@gmail.com', 'Email Works', $text)) {
echo '<p>Mail sent successfully.</p>';
}
else {
echo '<p>Mail could not be sent.</p>';
}
另外,检查您的电子邮件和php设置,以确保您可以使用邮件功能。
设置邮件服务器了吗?
您可能没有在服务器上安装邮件服务器。如果您使用的是XAMPP,请在php.ini中设置XAMPP上的邮件设置。
这个链接可以帮助你设置smtp的设置
试试下面的代码
if ($mail('email@gmail.com', 'Email Works', $text)) {
echo('<p>Mail sent successfully.</p>');
}
else {
echo('<p>Mail could not be sent.</p>');
}