<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: yoursite.com';
$to = 'contact@yoursite.com';
$subject = 'Customer Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
我试过创建一个简单的邮件表单.表单本身在我的index.html页面上,但提交单独的"谢谢你的提交"页面thankyou.php,其中嵌入了上面的PHP代码.代码提交完美,但从不发送电子邮件.请帮忙.
我按照以下链接中描述的步骤设置我的mac发送电子邮件. http://www.anujgakhar.com/2011/12/09/using-macosx-lion-command-line-mail-with-gmail-as-smtp/
它在我的Mac OS X 10.9上运行良好.但是在我升级到OS X 10.10之后.mail.log显示以下错误.问题是什么?
Oct 19 00:28:22 paullam-macbook-pro.local postfix/smtp[30383]: 6B47B8AD4E8: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.68.109]: generic failure
Oct 19 00:28:24 paullam-macbook-pro.local postfix/smtp[30383]: 6B47B8AD4E8: to=<zzpaul@gmail.com>, relay=smtp.gmail.com[74.125.68.108]:587, delay=3.4, delays=0.01/0/3.4/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.68.108]: generic failure)
Run Code Online (Sandbox Code Playgroud)