我试图让PHP向我的电子邮件帐户发送电子邮件,但它给了我这个错误:
http://gyazo.com/5e7870a814be520f2ba2dec32627c7e5
这是我在contact_me.php
<?php
// Check for empty fields
if( empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)
) {
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'yourname@yourdomain.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
谢谢你们!
答案 0 :(得分:1)
如果您使用的是ubuntu,则需要配置sendmail或postfix以发送电子邮件。
使用以下链接配置postix:http://crazybrainz.in/configauration-of-postfix-for-mail-sending-through-php-and-magento/
提供更多信息来解决您的问题。