简体   繁体   中英

Amazon EC2 Email can only send to Yahoo Mail, Not Gmail

I have had a small issue with my EC2 email capabilities. While I am able to send emails from ec2 to my Yahoo Mail account, Gmail stopped receiving my EC2 emails as of 23 hours ago (ie, 23 hours ago, I could do the following and it would work.

mail("jetmail250@gmail.com", $subject, $message, $headers). 

The code I use to send mail from my EC2 server is shown below. I checked all my spam box, filters, etc. in Gmail and have not seen any mail sent to my Gmail. In order to isolate the problem, I sent redirected all the messages sent from my EC2 from my Gmail to my Yahoo. And EC2 does successfully send emails to my Yahoo Mail account, with the modified code hilighted in orange below

I use this email feature on my website (www.JethroChan.com/contact.php) to allow people to use my form to send me emails directly from my website. My Gmail is the sole reciever of these emails from my Website's contact form.

<?php
  //send email
  $subject = $_REQUEST['subject'] ;
  $headers = $_REQUEST['headers'] ;
  $message = $_REQUEST['message'] ;
  mail("jetmail250@yahoo.com (this was @gmail.com to a Valid Gmail account earlier)", $subject, $message, $headers);

  //echo "Email Sent!";

?>

Please help me see why only Yahoo, and Not Google is capable of receiving my EC2 emails as of today :D

Generally speaking, its not recommended that you sent email directly from an ec2 instance. They have been used and and abused by spammers since day one, and many many email ISPs have taken the drastic step of blacklisting the entire range IP's used by EC2 from receiving email, just assuming it is all spam.

Much better to use amazon SES, which will cost next to nothing and is very simple drop-in replacement for your SMTP. It needs to be setup/verified, but after that it is pretty seamless. For what you are doing, it will probably cost you less than 10 cents a month.

http://aws.amazon.com/ses/

In order to maintain the quality of EC2 addresses for sending email, we enforce default limits on the amount of email that can be sent from EC2 accounts. If you wish to send larger amounts of email from EC2, you can apply to have these limits removed from your account by filling out this form

You can test mail connectivity with a simple telnet application :

  1. find the address of the GMAIL mail relay

```

$ dig gmail.com

; <<>> DiG 9.8.3-P1 <<>> gmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16340
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;gmail.com.         IN  A

;; ANSWER SECTION:
gmail.com.      300 IN  A   173.194.65.83
gmail.com.      300 IN  A   173.194.65.17
gmail.com.      300 IN  A   173.194.65.18
gmail.com.      300 IN  A   173.194.65.19

;; AUTHORITY SECTION:
gmail.com.      108850  IN  NS  ns1.google.com.
gmail.com.      108850  IN  NS  ns2.google.com.
gmail.com.      108850  IN  NS  ns4.google.com.
gmail.com.      108850  IN  NS  ns3.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.     24566   IN  A   216.239.32.10
ns2.google.com.     173323  IN  A   216.239.34.10
ns3.google.com.     173323  IN  A   216.239.36.10
ns4.google.com.     173323  IN  A   216.239.38.10

;; Query time: 46 msec
;; SERVER: 77.241.230.245#53(77.241.230.245)
;; WHEN: Sat Mar 29 08:18:46 2014
;; MSG SIZE  rcvd: 234
  1. telnet on port 25 and issue the following sequence :

```

$ telnet 173.194.65.83 25
Trying 173.194.65.83...
Connected to ee-in-f83.1e100.net.
Escape character is '^]'.
220 waldorf.attingo.nl ESMTP Exim 4.74 (Debian) Sat, 29 Mar 2014 08:21:56 +0100
helo sst
250 waldorf.attingo.nl Hello sst [77.241.230.246]
mail from:<seb@example.com>
250 OK
rcpt to:<seb@myaddress.com>
250 Accepted
data
354 Enter message, ending with "." on a line by itself
From:Seb
To:Seb
Subject:Test

Hello SMTP
.
250 OK id=1WTnb2-0003N9-2g
quit
221 waldorf.attingo.nl closing connection
Connection closed by foreign host.

(be sure to substitute the Mail From and RcptTo: with valid email addresses)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM