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設置,以便進行特定的郵件服務。 –