We are trying to figure out how to reduce the amount of bounces for our email platform and, one of the solutions we've found on the internet is to, via telnet, verify if the email exists.
So, for this example, we connect to the MX:
telnet alt4.aspmx.l.google.com 25
We start the communication:
helo hi
And, for every email we try (valid and invalid ones), we always receive the same response:
mail from: <fsafsaffsf#FasgagaoaSFasfas.co>
250 2.1.0 OK d8si998940wrc.143 - gsmtp
Are they doing this to prevent maybe a possible listing of valid emails?
What is the best way to verify if an email is valid before sending an email to it? We need this because our clients often uploads a spreadsheet with customer emails and always one or two of them are mistyped.
Thanks.
For a given recipient email address, you can:
extract its domain name (everything after #)
query DNS for the MX record(s) of that domain
for each specified server, connect and issue a VRFY command (see RFC 5321 Section 3.5), asking the server to verify the email address.
stop when you get a success reply.
However, SMTP servers are not required to implement VRFY. The simpler solution would be to just send the email normally, and then handle any errors from the RCPT TO command, and also handle the possibility that you simply can't always detect delivery errors in real time. If the email has to be relayed across servers, it might not fail on the server you use for sending, it may not fail until it is relayed to another server after you have already ended your SMTP session. In which case, the only way to detect delivery errors is to monitor your inbound mailbox for delivery failure emails being sent back to you.
I use Thunderbird with an IMAP server to access incoming email as well as for online storage of mail, and SMTP server for outgoing email. Every time I send an email, it first sends it via SMTP and then uploads it separately to my IMAP server's Sent Items folder. This is not only inefficient, it's also risky as sometimes, on a poor-quality connection, I can send out an email by SMTP but then fail to save it on the server with IMAP, leaving me without any copy of the email I sent (and Thunderbird doesn't save it in the outbox in such cases).
Is there any way I can set up some local and/or server-side software such that (1) the mail only needs to be uploaded once and (2) it will reliably appear in my Sent Items immediately, without delay (and without requiring it to be re-downloaded) and then also hopefully (3) when my connection is poor and an email can't be saved to the IMAP folder, it automatically stays in my local outbox until properly sent and synched?
Local mail clients have been around for so long now, I am really surprised that there appears to be no solution for this! Seems like webmail is the only robust solution, but that's no good for poor quality connections either.
I am thinking of solutions like offlineIMAP and dovecot, but wondered if anyone has got/seen an outline for how such a setup could be organised?
This is not possible using imap, the protocol just don't manage at all the sending of messages.
You could manage to do that using sieve scripts while telling postfix to deliver the message to the sender but that won't be robust and would save the email two times in the Sent folder if the client is not configured for your liking.
Overall, this is a bad idea.
From https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol#Disadvantages:
"Unlike some proprietary protocols which combine sending and retrieval operations, sending a message and saving a copy in a server-side folder with a base-level IMAP client requires transmitting the message content twice, once to SMTP for delivery and a second time to IMAP to store in a sent mail folder. This is remedied by a set of extensions defined by the IETF LEMONADE Working Group for mobile devices: URLAUTH (RFC 4467) and CATENATE (RFC 4469) in IMAP and BURL (RFC 4468) in SMTP-SUBMISSION. POP servers don't support server-side folders so clients have no choice but to store sent items on the client. Many IMAP clients can be configured to store sent mail in a client-side folder, or to BCC oneself and then filter the incoming mail instead of saving a copy in a folder directly. In addition to the LEMONADE "trio", Courier Mail Server offers a non-standard method of sending using IMAP by copying an outgoing message to a dedicated outbox folder.[18]"
I like the idea of a clever IMAP server that handles handing off a message via SMTP through the use of an outgoing message folder, which the Courier Mail Server seems to be doing.
The set-up would need a 'smart' local SMTP server (defined below) as well as either a normal online IMAP server or else alternatively a local/offline IMAP server capable of keeping local offline copies of everything and synchronising when connected.
The 'smart' local SMTP server would need to handle the job of arranging for the message to be sent. In one configuration, it could simply do this as normal. But in another configuration, it could communicate with a 'smart' remote SMTP server, and, instead of sending the outgoing message to that server, it could tell that other server that the remote IMAP server has whatever particular message and, then the remote SMTP server could fish out the message from the remote IMAP server and send it on its way.
Such a configuration could be managed without a special email client. The only change from a standard configuration would be (1) setting IMAP to save sent messages in an 'outgoing' folder, and (2) setting the SMTP server to the 'smart' local SMTP server instead of the normal remote SMTP server.
None of this exists, but it could be implemented fairly easily by someone who was comfortable with both SMTP and IMAP protocols and server implementations, right?
I have an e-mail account with hostgator. I would like to build a console application (later a service application) that will check a mysql database for e-mails that need to be sent out and will process them by sending a certain number of e-mail every so many seconds. These e-mails will each have a 2-3mb pdf price sheet attached to be sent to our regular customer base. About 500 are set up to receive e-mails.
My question is: Should I connect to hostgator directly and send the
e-mails or should I use the IIS Virtual Server Relay and have it
connect to hostgator?
The only thing I can think of is if Hostgator were down the virtual relay might be a good option since it has retries. There again, I guess I could put some try/catch in the code where if it doesn't connect to hostgator or if their is a problem it will go to the timer and wait x minutes before retrying to process e-mails.
We have found that the easiest approach is to generate the outgoing emails and drop them in the inetpub\mailroot\pickup folder and let the SMTP service handle them (you can set it up to forward the emails to the appropriate host).
This falls firmly under the category of not re-inventing the wheel: the SMTP service easily handles the situation when the connection to the mail server is down, retries, and all of the other "fun" stuff that you would otherwise have to implement in your code if you handle the SMTP sends directly.
We have set up a system where notifications get sent to a user with the following From address format: user-{0}#aol.com (replace {0} with an ID)
This way we can track what user we sent the message to originally. This format is not likely to change for various reasons. The issue we are running into is this: every email we send out with a dynamic address is creating a new SMTP relay.
My knowledge of relays is very limited. Our host (GoDaddy) limits SMTP relays to 250 per day. This is an application that potentially will be sending out thousands of emails per day.
Is my assumption that every 'unregistered' email address we use opens a new relay, correct? If so, are there any services or hosts that provide unlimited relays for a reasonable price?
Thanks.
so my assumption that every 'unregistered' email address we use opens a new relay, correct?
Relay is basically a classification. every email sent via relay opens an SMTP connection on the mail server and not "a new relay"...that said, It might be cheaper, if you can, to set up your own sending SMPT server. It comes as a component of IIS. If you need any additional information on setting this up, let me know.
Godaddy, yes, due to the different plans. You can try any other email providers like google and yahoo as well. Just make sure to setup a "catch" all mailbox for undelivered mails and any responses.
For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...
The way I understand it, outgoing mail has to make three trips:
Client (gmail user using Thunderbird) to a server (Gmail)
First server (Gmail) to second server (Hotmail)
Second server (Hotmail) to second client (hotmail user using OS X Mail)
As I understand it, step one uses SMTP for the client to communicate. The client authenticates itself somehow (say, with USER and PASS), and then sends a message to the gmail server.
However, I don't understand how gmail server transfers the message to the hotmail server.
For step three, I'm pretty sure, the hotmail server uses POP to send the message to the hotmail client (using authentication, again).
So, the big question is: when I click send Mail sends my message to my gmail server, how does my gmail server forward the message to, say, a hotmail server so my friend can recieve it?
Thank you so much!
~Jason
Thanks, that's been helpful so far.
As I understand it, the first client sends the message to the first server using SMTP, often to an address such as smtp.mail.SOMESERVER.com on port 25 (usually).
Then, SOMESERVER uses SMTP again to send the message to RECEIVESERVER.com on port 25 (not smtp.mail.RECEIVESERVER.com or anything fancy).
Then, when the recipient asks RECEIVESERVER for its mail, using POP, s/he recieves the message... right?
Thanks again (especially to dr-jan),
Jason
The SMTP server at Gmail (which accepted the message from Thunderbird) will route the message to the final recipient.
It does this by using DNS to find the MX (mail exchanger) record for the domain name part of the destination email address (hotmail.com in this example). The DNS server will return an IP address which the message should be sent to. The server at the destination IP address will hopefully be running SMTP (on the standard port 25) so it can receive the incoming messages.
Once the message has been received by the hotmail server, it is stored until the appropriate user logs in and retrieves their messages using POP (or IMAP).
Jason - to answer your follow up...
Then, SOMESERVER uses SMTP again to send the message to RECEIVESERVER.com on port 25 (not smtp.mail.RECEIVESERVER.com or anything fancy).
That's correct - the domain name to send to is taken as everything after the '#' in the email address of the recipient. Often, RECEIVESERVER.com is an alias for something more specific, say something like incoming.RECEIVESERVER.com, (or, indeed, smtp.mail.RECEIVESERVER.com).
You can use nslookup to query your local DNS servers (this works in Linux and in a Windows cmd window):
nslookup
> set type=mx
> stackoverflow.com
Server: 158.155.25.16
Address: 158.155.25.16#53
Non-authoritative answer:
stackoverflow.com mail exchanger = 10 aspmx.l.google.com.
stackoverflow.com mail exchanger = 20 alt1.aspmx.l.google.com.
stackoverflow.com mail exchanger = 30 alt2.aspmx.l.google.com.
stackoverflow.com mail exchanger = 40 aspmx2.googlemail.com.
stackoverflow.com mail exchanger = 50 aspmx3.googlemail.com.
Authoritative answers can be found from:
aspmx.l.google.com internet address = 64.233.183.114
aspmx.l.google.com internet address = 64.233.183.27
>
This shows us that email to anyone at stackoverflow.com should be sent to one of the gmail servers shown above.
The Wikipedia article mentioned (http://en.wikipedia.org/wiki/Mx_record) discusses the priority numbers shown above (10, 20, ..., 50).
You're looking for the Mail Transfer Agent, Wikipedia has a nice article on the topic.
Within Internet message handling services (MHS), a message transfer agent or mail transfer agent (MTA) or mail relay is software that transfers electronic mail messages from one computer to another using a client–server application architecture. An MTA implements both the client (sending) and server (receiving) portions of the Simple Mail Transfer Protocol.
The terms mail server, mail exchanger, and MX host may also refer to a computer performing the MTA function. The Domain Name System (DNS) associates a mail server to a domain with mail exchanger (MX) resource records containing the domain name of a host providing MTA services.
You might also be interested to know why the GMail to HotMail link uses SMTP, just like your Thunderbird client. In other words, since your client can send email via SMTP, and it can use DNS to get the MX record for hotmail.com, why doesn't it just send it there directly, skipping gmail.com altogether?
There are a couple of reasons, some historical and some for security. In the original question, it was assumed that your Thunderbird client logs in with a user name and password. This is often not the case. SMTP doesn't actually require a login to send a mail. And SMTP has no way to tell who's really sending the mail. Thus, spam was born!
There are, unfortunately, still many SMTP servers out there that allow anyone and everyone to connect and send mail, trusting blindly that the sender is who they claim to be. These servers are called "open relays" and are routinely black-listed by smarter administrators of other mail servers, because of the spam they churn out.
Responsible SMTP server admins set up their server to accept mail for delivery only in special cases 1) the mail is coming from "its own" network, or 2) the mail is being sent to "its own" network, or 3) the user presents credentials that identifies him as a trusted sender. Case #1 is probably what happens when you send mail from work; your machine is on the trusted network, so you can send mail to anyone. A lot of corporate mail servers still don't require authentication, so you can impersonate anyone in your office. Fun! Case #2 is when someone sends you mail. And case #3 is probably what happens with your GMail example. You're not coming from a trusted network, you’re just out on the Internet with the spammers. But by using a password, you can prove to GMail that you are who you say you are.
The historical aspect is that in the old days, the link between gmail and hotmail was likely to be intermittent. By queuing your mail up at a local server, you could wash your hands of it, knowing that when a link was established, the local server could transfer your messages to the remote server, which would hold the message until the recipient's agent picked it up.
The first server will look at DNS for a MX record of Hotmail server. MX is a special record that defines a mail server for a certain domain. Knowing IP address of Hotmail server, GMail server will sent the message using SMTP protocol and will wait for an answer. If Hotmail server goes down, GMail server wiil try to resend the message (it will depend on server software configuration). If the process terminates ok, then ok, if not, GMail server will notify you that he wasn´t able to deliver the message.
If you really want to know how email works you could read the SMTP RFC or the POP3 RFC.
All emails are transferred using SMTP (or ESMTP).
The important thing to understand is that the when you send message to someguy#hotmail.com this message's destination is not his PC. The destination is someguy's inbox folder at hotmail.com server.
After the message arrives at it's destination. The user can check if he has any new messages on his account at hotmail server and retrieve them using POP3
Also it would be possible to send the message without using gmail server, by sending it directly from your PC to hotmail using SMTP.
Step 2 to 3 (i.e. Gmail to Hotmail) would normally happen through SMTP (or ESMTP - extended SMTP).
Hotmail doesn't send anything to a client via POP3. It's important to understand some of the nuances here. The client contacts Hotmail via POP3 and requests its mail. (i.e. the client initiates the discussion).