How does email delivery work between mail servers? - email

How does an email address actually work?
I know how dns translates domain names into IP addresses so that it knows where the person wants to go, but I have no idea how email addresses work.
Thanks in advance,
Francis

The very short answer is: using MX records.
The domain-part (i.e. the stuff to the right of the #-character) is used in a DNS query to find the MX records for that domain. Like there are A-records for finding IP addresses, MX records stand for mail exchanger records and points to one or more servers that are responsible for all emails to the specified domain.
When you send an email, your email server finds the MX records for the recipient's domain and delivers the email to that server. The part to the left of the #-character in the email address then identifies the specific mailbox at that server.

Related

How does GMail let users use their own custom email

I was trying to sign up for a new Gmail address and noticed that Gmail has an option in which you can use your custom email address without the need for having a GSuit paid membership.
Upon filling up the details, Gmail sends an OTP/code to the custom email and upon entering the right code the user can log in using that email.
How is it possible for Gmail to just get access to an email address without even the need for entering the password?
You are creating a google account. A Google account can be associated with any email id.
If you use a custom email id, you can use all the gsuite features like docs etc from that email id, but you cannot access your email via gmail.
To use gmail on a custom domain you have to pay ( change mx servers etc also )
This is done by using MX records.
Mail Exchange (MX) records are DNS records that are necessary for delivering email to your address.
In simple DNS terms, an MX record is used to tell the world which mail servers accept incoming mail for your domain and where emails sent to your domain should be routed to. If your MX records are not pointed to the correct location, you will not receive email.
MX records consist of two parts: the priority and the domain name. For example:
0 mail.EXAMPLE.com
The ‘0’ is the priority.
The lower the number means a higher priority.
The ‘mail.EXAMPLE.com’ is the mail server to which it connects. This is different - depending on what company is hosting your email.
Outgoing email servers connect to the MX servers in order of priority.
If you use more than one MX record and both have the same priority, it picks one at random. (This in effect load balances the connections.)
Your MX records are controlled at the company where your Nameservers are pointed.
Use MX records, provided by the G Suite Setup Wizard, to verify your domain (if you haven’t already verified it) and to set up Gmail as your professional email.
After you've switched to Google's MX records, you can receive your email in your Gmail inbox or through an email client like MS Outlook.
How it works
Keep setup instructions open and sign in to your domain host in another window or tab. Your host manages technical settings for your domain.
You’ll then update the MX record settings to direct your email to your G Suite account. It’s like registering a new address with the post office so that your mail gets delivered.
If you already use email with your domain (your email address ends with #yourdomain.com), you’ll start receiving messages in Gmail instead of with your old email provider.
Read more here https://support.google.com/a/answer/140034?hl=en

Spam mails Joe-Job via Amazon AWS

since a few days our internal email info#ourdomain.com seems to go bananas and sends out emails to all sort of email addresses. Some of those emails bounce and we receive Mail Delivery Failed emails every minute.
Here is our setup:
Domain hosted at Germany's 1und1 provider
Nameserver configured on Amazon Route 53
MX server mx01.kundenserver.de and mx00.kundenserver.de
Rails application hosted on heroku
I called the support at 1und1 and they told me to set a SPF record which I did:
"v=spf1 a mx ~all"
after researching the topic via http://www.spf-record.de/
Unfortunately this did not resolve the problem.
Honestly I am cluesless now what to do to prevent this random email sending.
Our account could have been hacked but the password was already changed.
Any of your email account or script/code compromise can cause outgoing spam emails. If outgoing emails are originating from particular email account and you find large outgoing email account from particular email account, you should consider to reset the password of that email account immediately. Also, compromised email sending script/code can can cause outgoing spam.
If "from" email address on spam email is none of your existing account then "From" email address is getting authenticated from any of your existing email account for which you should inspect SMTP logs of mail server(you should have administrative access of mail server)
Mail server IP address should not be blacklisted,please check IP here :- http://mxtoolbox.com/blacklists.aspx
If IP address is blacklisted, you can request IP whitelist after you identify and fix the outgoing spam source as RBL keeps IP address blacklisted until they find the spamming activity relaxed.
SPF and PTR record should be correct so that email recipient server can trust the sender mail server.
Bounce back email and spam email header can help to identify the issue more preciously.
This happened to me before, I had a "refer a friend" feature on my website and someone use an automated script to send emails to a ton of people. My server wasn't comprised, it was just bad coding in the feature that I installed that allowed my mail server to send mail to different people on my behalf.
Since the email is coming from you, your SPF/DKIM will check out just fine.
So thing about all the points on your website that can send email and see if any of them can be compromised.
Also you'll want to do a blacklist scan, I use this service it does more then 200+ blacklist: https://www.unlocktheinbox.com/blacklist/bl/
Make sure you scan both your domain name and IP address. But before you take any action to remove yourself, you should wait 24 hours until after you fix the exploit on your system. Requesting removal and popping up again can get you permanently listed.

Sending emails from my domain with SendGrid

I have a question that I guess is not just related to SendGrid.
Say, I own the mydomain.com domain, and I want to be able to send emails from, for example, team#mydomain.com.
Right now, when I go and manage my domain, I can see that I have added some MX record values added there. By doing this, I am able to send email using Gmail.
However, with Sendgrid I find this a little bit more confusing. I have read through the documentation, but I fail to see what should I do. I am using NameCheap, and all it comes to my mind is the following:
If I want to use Sendgrid to send emails from my application (Ruby on Rails), will I still be able to access my Gmail account and send emails using the same address (team#mydomain.com)? Is it compatible to have both (Gmail and Sendgrid) configuration in my domain?
Why don't I need to add any MX records for SendGrid?
First and foremost, the MX records for your domain are used only to specify the hostnames of the servers to handle INCOMING mail for your domain - i.e. the MX records have nothing to do with the servers that are used to send outgoing mail. You can use both Gmail's outgoing mail servers and Sendgrid's outgoing mail servers (and any other outgoing SMTP servers for that matter) to send outgoing mail for you domain. The only caveat to this is if you have an SPF record setup for your domain, but you didn't mention one so I won't elaborate.
MX records, as stated previously, are for specifying a server that handles INCOMING emails. You can use Sendgrid to send outgoing emails together with an email account service like Gmail. With Gmail, you would both send and receive emails. With Sendgrid, you would only send emails.
the MX records for the domain would be specified as those for Gmail/Google. The trick is in correctly configuring the SPF records, which is a TXT type record in the domain name. In the SPF record, you would include both Gmail/Google info as well as Sendgrid info on the same line.
So, say you only used Gmail for sending and receiving email, your SPF record would look something like this:
v=spf1 include:_spf.google.com ~all
However, if you add another server from another service, say Sendgrid, in order to also send verified emails for that domain, the SPF would be altered to something like this:
v=spf1 include:_spf.google.com include:u826348.wl.sendgrid.net -all
In both of these examples, only the GMail/Google MX records would be added to the DNS records.

Allow to send mail from domain with SPF record

I have question concerning SPF records.
The website (eg www.example.com) of one of my clients has a contact form that sends mails to contact#example.com.
We only provide the hosting of the website so we do not manage email accounts, DNS records, etc .. only webspace. So my clients manages the DNS settings, nameservers, mail servers, etc..
The mails are sent using PHP but they are never received by contact#example.com
When I change contact#example.com to an email address outside the domein eg contact#test.com, I do receive the contact email.
My conclusion is that their mailserver blocks mails from our IP address because PHP sends mails to an email address that has the same domain but has another IP.
Also, my client uses Google Apps for email so the MX records on their DNS server point to Google.
How can I fix this issue? Does my client need to add an SPF record that accepts our IP address? If so, whats the correct SPF syntax for this?
If your the domain has SPF records defined then you need to add the address of the web server to the SPF records.
You can check the SPF records of the domain on this website: http://spf.myisp.ch
The best way would be to check the log files on the web server or on the server of the receiver to find out what the problem is.
Make sure cpanel does not have any MX records since you are not hosting the dns

What should I use for SPF record of my domain?

I have example1.com hosted on host.example2.com. Typical cpanel scenario. And:
And example1.com is installed with Magento which sends many sorts of emails to the users from host.example2.com.
And I also set up example1.com with Google Apps with its MX entries as required by them.
Very typical. So I came up with this SPF record for example1.com:
v=spf1 a mx include:host.example2.com include:_spf.google.com -all
Is this correct?
It seems not because when I used the on-site contact form on example1.com to send a test visitor message (which was sent to my Google Apps email from host.example2.com), the email I received in Google Apps inbox was still with a 'via' field (via host.example2.com). I figure this means Google email takes this message to be not sent by example1.com ITSELF?
This record has been created since 2 days ago and the 'via' field was still present when example1.com tries to send a message from the server of host.example2.com.
If anyone could enlighten me on this that'd be really appreciated! Thanks!
The SPF record has nothing to do with the way the receiving server identifies the transmitting server.
The receiving server identifies the transmitting server by its IP address, a reverse DNS lookup on that IP address, and the HELO name it gives at the start of the mail session.
On the other hand SPF is used to determine if the transmitting server is authorized to use the envelope reverse-path address and HELO name.