2013-02-08 68 views
1

我使用一些代碼將數據發送到其還發送確認電子郵件已輸入到表單字段電子郵件似乎只被發送到Gmail的

一些奇怪的原因的電子郵件地址數據庫,它似乎只發送給我的Gmail帳戶,並沒有別的如Hotmail Tiscali公司雅虎

這裏是我用來發送電子郵件

// 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 <[email protected]>\r\n"; 
$headers .= "Reply-To: <[email protected]>\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"; 
+0

你應該看看[SwiftMailer](http://swiftmailer.org/)或[Pear](http://pear.php.net/package/Mail/redirected)。嘗試一下,看看它是否適合你。 – 2013-02-08 20:22:34

+0

你用簡單的電子郵件正文試過了嗎? (沒有html,少了文字) – 2013-02-08 20:30:51

+0

嘗試像'mailmetrash.com'或'10minutemail.com'這樣的一次性服務,看看它是否到達那裏。如果確實如此,但仍然不是雅虎/ Hotmail,請確認它沒有以垃圾郵件結尾。如果您使用共享主機,很可能大多數電子郵件提供商會將其標記爲垃圾郵件。 – 2013-02-08 20:31:16

回答

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("[email protected]" => "SOMEBODY LOVES YOU")) 
      ->setTo(array($receiveremail)) 
      ->setBody($body, 'text/html'); 

$mailer->send($message); 
+0

從這段代碼中,我如何發送2個不同的郵件到$ youremail和$ receiveremail?阿洛斯,所以我只是取代我的代碼或我需要包括一些其他文件?我現在很迷茫 – 2013-02-08 20:45:36

+0

你應該在開始的時候以不同的方式解決這個問題。我要說的是效率不高,但我相信你處於你的學習階段。 $ $ body1和$ body2變量用於$接收器,另一個用於$ youremail。重複$ message1接收器和$ message2 youremail。相應地更改變量,直到您學習OOP爲止,您都會很開心。 – u54r 2013-02-08 21:01:39

+0

我是否需要包含任何其他文件或只是替換我的? – 2013-02-08 21:07:16

0

這聽起來像這是不是你的代碼的問題。如果它到達一個郵件提供商而不是另一個,則其他提供商將阻止它或將其標記爲垃圾郵件。

此時需要考慮確保MX記錄和其他DNS記錄正確設置以識別您的服務器。

您的域名/ IP也可能被列入黑名單。在這種情況下,每個郵件提供商都可以採取措施讓他們擺脫黑名單。

+0

似乎電子郵件直接去垃圾郵件...任何方式來防止這種情況? – 2013-02-08 20:55:13

+0

這是一個更適合serverfault.com的問題。這基本上歸結爲設置公共記錄,說你不是一個骯髒的垃圾郵件發送者。可能涉及讓你從黑名單中刪除。 – BOMEz 2013-02-08 21:15:53

1

從技術上說,Gmail在協議方面與其他電子郵件服務完全相同,所以我猜這不是代碼相關的問題。

我檢查什麼是你傳出的電子郵件服務器和域,尤其是兩件事情:

這些電子郵件防僞技術。某些電子郵件服務會自動拒絕沒有SPF和DKIM的郵件。

+0

MX和DNS記錄是否也包含在內?我對電子郵件協議知之甚少,但我記得當我最後一次處理電子郵件問題時,這些問題都是一個問題。 – BOMEz 2013-02-08 21:23:04

+0

MX記錄用於接收郵件,因此應該可以。 DNS記錄是所有這些域相關記錄的廣義術語,包括MX,SPF和DKIM。查看您的域名註冊商的網站,瞭解有關配置SPF和DKIM的一些提示。 – gronostaj 2013-02-08 22:28:56