Not receiving mails to gmail from aws instance server - php

I am facing problem in receiving mail to my Gmail from a contact form on my website. Contact form is connected to a small PHP script. My website is uploaded on aws instance server and DNS on route 53.
Everything is updated in DNS (route 53) like MX records, SPF, DKIM, DMARC and everyday I got DMARC report but not receiving any mails for the contact form.
Below are the details
PHP script
<?php
$to = "info#mydomain";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: sender#example.com";
mail($to,$subject,$txt,$headers);
?>
MX records
1 ASPMX.L.GOOGLE.COM
5 ALT1.ASPMX.L.GOOGLE.COM
5 ALT2.ASPMX.L.GOOGLE.COM
10 ALT3.ASPMX.L.GOOGLE.COM
10 ALT4.ASPMX.L.GOOGLE.COM
SPF
"v=spf1 include:_spf.google.com ~all"
DKIM
The key which is provided by google
DMARC
"v=DMARC1; p=none; rua=mailto:info#mydomain"
These are the details updated on amazon DNS route 53 and still, I am not getting any mail.
Please anybody can help me with this.

There could be a number of reasons for this:
By default port 25 is blocked, if you're sending mail using this port you would need to consider using another port.
Many mail providers will also either reject or mark as spam emails that come from the EC2 IP ranges, primarily because it is easy for someone to setup a free tier account and send spoof emails.
The suggestion would be to connect to a mail service over another port. If you do not currently have one setup for sending take at Amazons offering with SES, using port 587 from your server you could send emails via this service with neither of the top 2 conditions to stop traffic being met.
If there is a specific reason for needing to use Port 25 Amazon do have a process for getting it unblocked for you, but you'll need to provide many steps to prove you are not going to abuse it.

By default, AWS instances are blocked from using PHPs native mail() function. Your code is doing just that.

Related

Is anybody able to send mails to gmail through AWS LAMP server using postfix, sendmail

I am using php mail function to send mails to gmail,yahoo accounts. I have a AWS LAMP instance, i have installed postfix and sendmail. I went through many forums infinite number of forums, still not able to send mails. After too many changes i was able to see Message accepted for delivery, but after some time got the same message.
stat=Deferred: Connection timed out with mta7.am0.yahoodns.net.
stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Just i am wondering is anyone able to send mails using the same scenario.
TLDR: Sending email is hard. Don't attempt final delivery yourself. Use AWS SES or another ESP.
As AWS is aware that spammers have, and will, try to send their mail from anywhere by any means, AWS explicitly prevents EC2 Instances from being able to send email without some effort. It is not in your best interest as a sender to attempt to send email directly, unless you understand very well the various mechanisms in place to securely send email, accurately identify yourself as a legitimate sender, and gain reputation on your EIP with ISPs. Primarily, AWS intends for you to use SES to send email outside your VPC.
How to use Sendmail with SES
How to request port 25 unblocked
I can't emphasize enough that businesses small and large choose to send their mail through a third party (an ESP, or Email Service Provider, like AWS SES) in order to resolve the many, many issues that will come up when attempting to do it all yourself. The various acronyms involved, all of which require their own research and understanding from various RFC's include: SPF, DKIM, and DMARC; there is also the regular maintenance required in monitoring whether or not your IP is currently, or in the future, blacklisted by the various RBL's that monitor Spam Traps; and, of course, list hygiene, or scrubbing your list for bounces (not doing these is a guaranteed path to staying in the spam folder, even if you finally succeed in sending email out port 25). Let an ESP do some of this for you.

PHP Mail SPF failure

We have a problem using PHP mail on a shared hosting server on 1and1.com
We use SPF entries in our TXT DNS settings which include the email servers we use also confirm that outgoing emails are sent from our domain email addresses.
The scenario is: We have a button feature that allows site users to send a personal email from their email address to a client email address.
The problem is: These emails either bounce or end up in SPAM because they do not pass the SPF test.
Although I realize that we can solve the problem with a dedicated server, I was hoping someone had a solution or a way that we could solve the problem and still remain on shared hosting.
Thanks!

What is the proper setup/architecture of postfix, phpmail, and and open mail relay service?

Setup:
Ubuntu 16.x, Postfix, PHPMailer
SocketLabs (mail relay service) - to send out server emails
Union Solution Exchange Server - to send and receive formal email from outlook
Im trying to send out emails from my ubuntu linux server that contain simple form data (name, message, phone etc).
I have been trying in vain to send emails from my PHP to emails, they send, but they get blocked as spam/junk.
I've recently switched mail services (from zoho to a solution union exchange server) and I cannot get past barracuda (even modifying whitelists / spam settings etc) with my own mail, but I can see them as junk in my hotmail. (cannot not send from mailserver#potlickers.com to support#potlickers.com). They get immediately canned and not delivered.
Solutions Union said I was spoofing the emails and I cannot whitelist my own domain I'm using and sending from? Ok. They suggested buying another domain. I now own potlickers.net.
They also mentioned I should take that domain and use it to send my emails via open relay (again socketlabs).
So, if my webserver is setup on a fqdm such as potlickers.com, and i send the mail from that server, how do i setup the correct architecture to send mails from potlickers.net to the open relayserver so my emails are free and clear and not spoofed?
Can i configure postfix to send mail from potlickers.net even though its hosting on blah.potlickers.com?
I understand to also add dkim and PTR.
Help stackoverflow1 - your my only hope. TIA much much mucho thanks.
So I think I got it.
Reconfigured postfix as a satellite. Pointed to smtp of relay mail server. Removed all SMTP settings in PHPmailer that point to server, and credentials.
Fire away - works like a charm.
Satellite server has the new domain potlickers.net versus the webserver domain potlickers.com
Seems to work ok for now. Will update moving forward.

MX record (Godaddy) How do I get contact form to send via shared hosting, but also recieve emails on my workspace email?

Sorry for the complicated title, I myself am not too sure what the problem is but essentially Godaddy only allows for 1 type of MX record - either mail.yourdomain.com or smtp.secureserver.net. They told me in order to have my php mail() contact form to work, I need to have mail.yourdomain.com as the MX. However, I also want to have a seperate email to receive incoming emails and that requires the smtp.secureserver.net as the MX entry.
My question is is there any way to get these two to work simultaneously?
Basically I want my server to send the contact form email on my site, while at the same time I receive emails in my Godaddy Workspace email client.
For outbound email you need to use GoDaddy's secureserver.net servers (covered many times on here, and in PHPMailer docs), but that has no bearing on inbound mail or your MX records. They are entirely independent, so I don't see any reason why your outbound server should have any bearing on what you use for outbound.
You can have multiple MX records, but you can't choose which gets used other than via priority field in your DNS, but that's not a reliable approach.

PHP mail() function sends the email but it takes more than 10 mins to show up

So my user signs up from the Android App on his phone and after sign up is successful I trigger a mail to be sent to the signed up email address with an Activation Passcode from my PHP script. Here is the line of code that I use which is pretty trivial.
mail($to, $subject, $message, $headers);
The mail is sent correctly every time to the correct email address but the problem is the email shows up in Gmail or Hotmail or Yahoo in more than 10 minutes. That kind of a latency for receiving an Activation Code for the App "to me" is unacceptable.
What can reduce this latency and make this if not instanteneous but a lot quicker. Any ideas.
Thank you all for your help!!
I had this issue with GoDaddy shared hosting, using their SMTP server. It was because the SMTP server was a shared, open relay, and with the volume of messages passing through it - there is a delay of roughly 10 minutes as well.
Are you on shared hosting/GoDaddy? What SMTP relay are you using?
EDIT: After researching this thoroughly very recently, I have found that there is no way to deliever a high quality of SMTP service (i.e. < 10 minutes for an email) to my audience on GoDaddy shared hosting. This is incredibly frustrating. Looks like the options are to buy dedicated hosting from GoDaddy (~$300/year), or to switch providers.
On top of everything else, the receiving end may be using greylisting, which basically bounces an email on the first delivery attempt, on the theory that spam sources won't bother retrying, while a legitimate server WILL re-try after a few minutes.
most likely it is your server, perhaps you have a anti-spam program or anti-virus program? If you are on a shared environment there may be a que.
I'll guess you're using some shared hosting which probably is using some q system and therefor the delay... If your really picky about getting your mail delivered at once i would recommend dedicated hosting
Try this service guys...awesome API integration. www.postmarkapp.com After lot of searching I integrated my Android App Account Activation email service to Postmark and works like a breeze. Mails started getting sent to users instantly and the latency was reduced from stupid Godaddy's 10 mins or more to within a minute. I highly recommend it.

Categories