php
  • email
  • ubuntu
  • smtp
  • sendmail
  • 2015-10-15 82 views 0 likes 
    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憑證。

    +0

    你必須先設置SMTP設置,以便進行特定的郵件服務。 –

    回答

    0

    試試這個: How to configure XAMPP to send mail from localhost?

    您可以使用其他郵件服務,不僅Gmail中。後來,當你有自己的服務器時,安裝你的郵件服務器:)

    相關問題