0
我想在ubuntu上使用xampp使用php mail()函数发送邮件。但它没有发送。请检查我的代码。我是否需要为Gmail设置任何类似Gmail的电子邮件服务器,或者我可以在没有Gmail的情况下执行此操作?发送邮件从本地主机没有Gmail是可能的?
<?php
$address = "[email protected]";
$subject = 'Test email';
$body = 'If you can read this, your email is working.';
echo "Attempting to email $address...<br />";
if (mail($address, $subject, $body)) {
echo 'SUCCESS! PHP successfully delivered email to your MTA. If you don\'t see the email in your inbox in a few minutes, there is a problem with your MTA.';
} else {
echo 'ERROR! PHP could not deliver email to your MTA. Check that your PHP settings are correct for your MTA and your MTA will deliver email.';
}
?>
如果我使用SMTP的Gmail帐户,其发送邮件,但不使用PHP的mail(),因为我不想分享我的Gmail凭证。
你必须先设置SMTP设置,以便进行特定的邮件服务。 –