电子邮件似乎只被发送到gmail

时间:2013-02-08 20:17:51

标签: php

我正在使用一些代码将数据发送到数据库,该数据库还会向输入表单字段的电子邮件地址发送确认电子邮件

由于一些奇怪的原因,它似乎只发送到我的Gmail帐户,没有别的像hotmail tiscali yahoo

这是我用来发送电子邮件的代码

 // this send the receiver an email with the link to their ecard
 mail("$receiveremail","Somebody loves you !", "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\"> 
 </p>
 <p>Hello $name,</p>
 <p>Someone you know has sent you a secret valentine's message from http://www.somebodylovesyou.co.uk </p>
 <p>You can view your message here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P>
 <P>Why not send a special someone a secret valentine's message at http://www.somebodylovesyou.co.uk</p>
 <P>Happy Valentines", $headers); 

 // this send the receiver an email with the link to their ecard
 mail("$youremail","View the message you've just sent", "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\"> 
 </p>
 <p>Hello,</p>
 <p>Thanks for using Somebody Loves You </p>
 <p>You can view the message you sent here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P>
 <P>Happy Valentine's", $headers);?>

我被建议使用这些标题以帮助发送电子邮件,但它似乎无法正常工作

 // these headers are for the purpose of sending the email replay to hotmail and yahoo addresses
 $headers = "MIME-Version: 1.0\r\n"; 
 $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
 $headers .= "From: SOMEBODY LOVES YOU <hello@somebodylovesyou.co.uk>\r\n"; 
 $headers .= "Reply-To: <hello@somebodylovesyou.co.uk>\r\n"; 
 $headers .= "X-Priority: 3\r\n"; 
 $headers .= "X-MSMail-Priority: Normal\r\n"; 
 $headers .= "X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409\r\n"; 
 $headers .= "X-Mailer: Microsoft Outlook Express 6.00.2800.1409";

3 个答案:

答案 0 :(得分:1)

从技术上讲,Gmail与协议的任何其他电子邮件服务完全相同,所以我想这不是与代码相关的问题。

我要检查的是您的外发电子邮件服务器和域名,尤其是两件事:

这些是电子邮件防伪技术。某些电子邮件服务会自动拒绝任何没有SPF和DKIM的邮件。

答案 1 :(得分:0)

尝试SwiftMailer它非常易于使用且非常强大

$body = "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\">   </p>  <p>Hello $name,</p>  <p>Someone you know has sent you a secret valentine's message from http://www.somebodylovesyou.co.uk </p>  <p>You can view your message here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P> <P>Why not send a special someone a secret valentine's message at http://www.somebodylovesyou.co.uk</p>  <P>Happy Valentines</p>";      
    $transport = Swift_MailTransport::newInstance();

     $mailer = Swift_Mailer::newInstance($transport);
     $message = Swift_Message::newInstance($subject)
             ->setFrom(array("hello@somebodylovesyou.co.uk" => "SOMEBODY LOVES YOU"))
             ->setTo(array($receiveremail))
             ->setBody($body, 'text/html');

$mailer->send($message);

答案 2 :(得分:0)

听起来这对您的代码来说不是问题。如果它到达一个邮件提供商而不是另一个邮件提供商,则其他提供商阻止它或将其标记为垃圾邮件。

此时您需要了解的内容,确保正确设置MX记录和其他DNS记录以识别您的服务器。

您的域名/ IP也可能已被列入黑名单。在这种情况下,每个邮件提供商都可以采取措施来取消黑名单。