如果@符号位于电子邮件行中提交的表单中,则不会发送电子邮件。即:如果您在电子邮件表单中键入bob,它可以工作,但bob@gmail.com没有。我该如何解决它才能正常工作?如果@符号在行中,则电子邮件根本不会发送。
<?php
$to = "MYEMAIL@gmail.com";
$name = $_POST['name'];
$email = $_POST['email'];
$add = $_POST['add'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$subject= "Request For Quote from Latva";
$message = "
Full Name - $name
Email - $email
Address - $add
City - $city
State - $state
Zip - $zip
Phone - $phone
Message - $comments
";
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: ".$name." <".$email.">\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
foreach($_FILES as $userfile)
{
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];
if (file_exists($tmp_name))
{
if(is_uploaded_file($tmp_name))
{
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
$message.="--{$mime_boundary}--\n";
if (mail($to, $subject, $message, $headers))
echo "Mail sent successfully.";
else
echo "Error in mail";
?>