我想在ubuntu上使用xampp使用php mail()函数发送电子邮件。但它没有发送。请检查我的代码。我是否需要为它设置任何电子邮件服务器,例如gmail,或者我可以在没有gmail的情况下进行设置?
<?php
$address = "kthakkar@argusoft.com";
$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.';
}
&GT;
如果我使用smtp gmail帐户,它发送邮件但不使用php mail(),因为我不想共享我的Gmail凭据。
答案 0 :(得分:0)
试试这个: How to configure XAMPP to send mail from localhost?
您可以使用其他邮件服务,而不仅仅是gmail。稍后,当您拥有自己的服务器时,请安装邮件服务器:)