What further happens after emails are received on SMTP ? Who Stores the email, is that SMTP? - smtp

I am developing a customized SMTP server, it is almost complete too. Other SMTP can now contact with my SMTP and I can successfully recive what they send to me. But now I am thinking is it responsibility of SMTP to store the received email OR I will have to pass recived values to any other program that stores these values(such as to,from,data) of recived emails. If so then what is that program ? If not then who will store received values, is that SMTP ??

What you've written is a Mail Transfer Agent (MTA). A piece of software that delivers mail to a user's mailbox is called a Mail Delivery Agent (MDA). The MDA can be a part of the MTA (that is, you can write code in your server that knows how to deliver to mbox, maildir, etc., as for instance Sendmail does), or it can be a separate program like procmail or maildrop.

If you would like to model your custom SMTP server after Postfix (which happens to be the only SMTP server I have experience with), Postfix implements the storing of emails in text files using Postfix-maildrop in the mbox format located at /var/mail/[username] (in the Ubuntu/Debian universe, this is where they live anyway).
I found more details in another thread listed below:
https://unix.stackexchange.com/questions/23277/where-does-postfix-store-email
Mbox format described:
http://en.wikipedia.org/wiki/Mbox
https://www.rfc-editor.org/rfc/rfc4155

Related

Setting up mail smtp relay service to send and receive mail

I have very limited knowledge about SMTP and IMAP/POP. SMTP --> sending message, IMAP--> Mainly for receiving messages.
I have a woocommerce website and i already did setup my email system to use SMTP relay using zoho. I believe zoho also provide mailbox services since I am able to communicate with my customer(both two and fro) using its email service. They have their app and i can receive and send mail from that app. Obviously, I have set up all the records including MX to send/receive the email to my zoho inbox.
No i want to move my email services to postmark or like sendinblue. All i can see the setting related to sending the mail but how/where will I receive the mail when user reply on that??
On the postmark website it says:
Since Postmark is not a mailbox provider there's not the ability to generate mailboxes for receiving email using IMAP or POP3.
Question 1) Does the SMTP relay server is actually a different physical machine from IMAP server for sending/receiving messages. I guess both are different but why are these companies not providing solutions like zoho. Pardon me if I did not understand the use case.
Question 2) What to do in this case ???. My case is simple. I send notifications to customers regarding their orders. If they want they can reply or enquire. I receive the email on my phone and I can reply on the same mail-chain like we have on Gmail.
Question 3)
Do i need to buy some another service along with these to receive and reply back on the email ??? Like from godaddy or somewhere else.

Client Side Only standalone Smtp Client/relay, for sending mails directly

Usually, when you send an e-mail (with Thunderbird or Outlook), you don't send it directly.
example: I have a gmail address and I want to send an e-mail to a myopera address. The process will be:
user->gmail server(gmail-smtp-in.l.google.com)->myopera server(in1.smtp.messagingengine.com)->final user who'll download it's email with pop/imap.
One of the inconvenient is the size: Imagine you have attachment of 50Mb: the limit of myopera is 60MB; but the limit of gmail is 25MB,So the mail will be refused whereas it would be accepted if it was send directly to myopera.
But I saw with telnet that, it is possible to send mail directly with SMTP commands.
I want to write a client-side Only web application which would convert a mail in a set of SMTP commands for sending it. I should be very basic and not support encryption
I don't know how to create a TCP connection from a client, so, here's my questions: Does a library already exist? If not, what I should use? I've read about the existence of WebSockets but that Ajax would be more universal.
Also, most of the actuals implementations of WebSocket I saw, don't work in my latests versions of web browser despite the fact they 'support it'. There's also the raw Socket API from the W3c (I've no idea of the web browsers which actually support it).So, I would like to not avoid statements telling it is impossible to create near raw TCP/UDP session. Since it is possible, I can't imagine nobody created a kind of library for dealing with protocols
You should take an alternative route.
If i had that issue i would still use a server side component of some sort, and just have the server contact to receiving mail server directly.
Given the email: "someuser#somedomain.tld" you could do a DNS MX record lookup on "somedomain.tld" and find the receiving mail server say "mail.somedomain.tld", then you could tell your mail send component to send the email directly to "mail.somedomain.tld", that way you would have an immediate feedback on whatever the mail went through or not.
For Objective-C you may use https://github.com/jetseven/skpsmtpmessage
By looking at the source you see how SMTP works.

Sending email to same/different domains

I am doing a Networks course and as I was reading about SMTP I thought about the following matter:
If a user sends an email to user1#example.com, user2#example.com, user3#example.com, does it take the same amount of time to send the emails separately as it does to send it as a multi-recipient email?
Or when the first one is sent, the next two are easier to send since the connection is already established with that server? Or does the connection close immediately thus making no difference?
What about when the emails belong to different domains?
It depends on how the MTA is programmed. The SMTP protocol allows the sender to send multiple RCPT TO commands, to list all the recipients of a message, and any reasonably-designed MTA will make use of this to consolodate them.
For the multiple-domain case, your mail client will use a single connection to upload the message to its submission server. That server will then use one connection per destination domain for the recipients.

How does a mail relayer doesn't send a mail to already received recipients?

i was wondering.
Suppose i have an exchange server, (the domain can be me#company.com),
also, i have a relay server, that accepts requests to internet domains (gmail/yahoo/etc).
suppose i send a mail to: (you#company.com; him#gmail.com) - from a user in the domain (me#company.com)
The mail is sent to the exchange server, then the exchange groups the domains (company.com and gmail.com) => it puts the mail into you#company.com mailbox.
then, the exchange sees that it needs to send into him#gmail.com, so it will send it to the relay server.
the relay server will get the SMTP request:
from: me#company.com
to: you#company.com; him#gmail.com
the question is - how does the smtp relay server knows not to send it to you#company.com - thus causing duplicate mails received?
also, how does the gmail server knows not to try to send the mails it receives again? (because they only get smtp requests, similar to a client that sends the mail)
thanks in advanced!
The content of the mail is not parsed by either exchange or the relay for determining where the mail should go. Everyone in this context is talking SMTP with one another, and specify recipients with the RCPT protocol message. So your mail client tells exchange two RCPT, exchange decides one of them is remote, then says one RCPT to the relay, and so on and so forth. This document specifies the SMTP protocol where you may read about the RCPT verb.
The headers you see are not used to deliver the message. Instead, SMTP defines a concept called envelope which has a completely different set of headers. As a common illustration, this is how Bcc: works, too; the recipient address is copied to the envelope, then removed from the message which goes inside the envelope.
When a message is delivered, the envelope sender is usually copied into the Return-Path: header, and you can sometimes see the envelope recipient information copied into the Received: headers.
At the point where a mail server decides to which destinations a message should go, there is commonly one copy of the message (spool file, queue entry, what have you) for each distinct destination. So if you send to from you#company to me#company, you#private, and friend#gmail, the first server might determine that the external addresses should both go to the same outbound relay, while the internal copy is delivered locally. Then the relay similarly decides that it needs to contact two distinct destination, so the single incoming message gets copied to two outbound messages, one to you#private and the other to friend#gmail.

Retrieve SMTP response of a mail

Is it possible to retrieve the SMTP response of a mail. For example, I am sending a mail to non existing email id. Surely our server will send us a mailer daemon failure mail to our mail id. I need to capture that failure mail.
How its possible? please explain me. Some time we may enter more than one non existing email id, so i have to retrieve all the failure mail alone for every corresponding emails
Please guide me!
Thanks in advance,
Praveen J
I think I understood your question correctly now. As I understand, you are writing an application to send mail. And in your application, whenever you send a mail, you also want verify that if mail was delivered and also if it was not delivered then you want to get hold of the failure message in your application. Is that how you mean?
Well, if that is how you mean, then I think it is impossible to track the mail status with your apllication code. For instance if you are using java sendMail in your apllication you can only ensure that the send happened from your code successfully(without any send exceptions like java.net.SocketException or javax.mail.MessagingException). But, you can never ensure if the mail really reached the recepient. i.e. you can never track in your application if the mail was rejected due to wrong recepient address or any other error like illegal attachment at receipient mail server or errors like blocked sender id etc.
That is because any such error condition will be communicated by the receipient mail server to the sending mail server the information of which is present in the sent mail's header.
Does that answer your question? (Or did I understand your question correctly? ;-))
I am not sure if I am getting your question right. If you send an email to any non existent address say xxx#gmail.com from your address yyy#yourhost.com, the mail server at gmail.com replies to the mail server at yourhost.com with failure message and reason, with your delivery address and you receive the fialure mail automatically. you don't have to do anything extra in this.
If you are talking about seeing mail headers, then it depends on which client you are using. For instace, if you are using MS outlook, you can right-click on the message and click options and then see internet headers section to get mail headers. If you are using some web based mail then i am sure there will some option to view detailed mail headers.
The bounced messages are going to return to a mailbox. You should be able to configure that mailbox by properly setting the headers on the messages you send out. You would then need to monitor that mailbox, or have that mailbox deliver the messages to your program.
I would suggest you consider using VERP for all messages you send out. It will make it much easier for you to identify which email address a particular bounce belongs too. To do this you would need control of your mail server though. It takes some work configuring things.
To answer the question with more detail you need to tell us how your are sending messages, what type of mail server you are running, and how much control you have over the mail server.
On Unix, you can use "procmail" for this. Procmail is a service which can intercept your mails and process them following rules.
If you can access your mail my IMAP, I suggest to look at the Python module imaplib.