1

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

出于某种奇怪的原因,它似乎只发送到我的 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";
4

3 回答 3

1

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

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

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

于 2013-02-08T21:14:05.800 回答
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);
于 2013-02-08T20:40:57.137 回答
0

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

此时,您要检查确保正确设置 MX 记录和其他 DNS 记录以识别您的服务器。

您的域/IP 也有可能被列入黑名单。在这种情况下,每个邮件提供商都有您可以采取的步骤来摆脱他们的黑名单。

于 2013-02-08T20:42:27.703 回答