Koozali.org: home of the SME Server

Contribs.org Forums => General Discussion => Topic started by: William R H on November 26, 2021, 02:45:55 PM

Title: Email processing - how do all the components work together?
Post by: William R H on November 26, 2021, 02:45:55 PM
Can I please test my understanding of what goes on and ask for corrections and help filling in the gaps? This is largely driven by an inadvertent exposure to a mailbot that sent several 100k messages by relaying them out through our server. That gruesome experience left me wondering exactly what goes on to make emails work. I know the individual components each have their man pages and wikis but which ones and how they are all configured to work together in Sme Server is not at all clear to me.

Even if a point I make is without qualification it doesn't mean it is correct - just my understanding. If I don't know I do put a ?

So hack away as you will.

I'm not sure if this counts as an idiot's guide or an email 101. No doubt the moment I press "Post" more points will occur to me but hey ho! here goes...


some questions...

Thanks for your time.
Title: Re: Email processing - how do all the components work together?
Post by: TerryF on November 26, 2021, 09:58:26 PM
Digging deep, going need the brighter ones to chip in here...jump in guys
Title: Re: Email processing - how do all the components work together?
Post by: mophilly on November 29, 2021, 11:41:04 PM
SNIP...
some questions...
  • what puts our dkim-signature into the headers? and when?
  • what decides if the dkim signature should be included and how?
  • what does sqpsmtpd do?
  • who deals with aliases, groups, forwarding,vacation messages etc etc?

I commend you for this post. It can only help.

I am no expert and probably a bit dangerous in posting a reply. Lack of wisdom never stopped me before, sooo...

1. DKIM is defined in the DNS zone record. The topic is complicated, but it boils down to updating your zone record with a properly formatted string. The devil is in the details.

2. I don't know, but I am going to take a look around.

3. sqpsmtpd handles secure smtp negotiations. It recieves the request from your client to send an email, then verifies that you can or not.

4. The system admin. You can add various contribs to provide convenience features, such as allowing the system user to set their own password, vacation message, and so on.

I hope this helps a bit. Please post more questions in this thread. It may be a great way to gather info to update the documentation.
Title: Re: Email processing - how do all the components work together?
Post by: warren on November 30, 2021, 11:57:48 AM
....
Thanks for your time.

qmail has multiple parts to it, below is some of the flows :
Code: [Select]
Mail remote to Local :

PIC.rem2local
qmail-smtpd     Receive message by SMTP from another host / localhost:

     |             MAIL FROM:<bill@irs.gov>
     |             RCPT TO:<joe@heaven.af.mil>
     |
     |          Is $RELAYCLIENT set? No.
     |          Is heaven.af.mil in rcpthosts? Yes.
     |          Accept RCPT.
     V

qmail-queue     Store message safely on disk.
                Trigger qmail-send.
     |
     V

qmail-send      Look at envelope recipient, joe@heaven.af.mil.
     |          Is heaven.af.mil in locals? Yes.
     |          Deliver locally to joe@heaven.af.mil.
     V

qmail-lspawn ./Mailbox

     |          Look at mailbox name, joe.
     |          Is joe listed in qmail-users? No.
     |          Is there a joe account? Yes.
     |          Is joe's uid nonzero? Yes.
     |          Is ~joe visible to the qmailp user? Yes.
     |          Is ~joe owned by joe? Yes.
     |          Give control of the message to joe.
     |          Run qmail-local.
     V

qmail-local joe ~joe joe '' '' heaven.af.mil bill@irs.gov ./Mailbox

                Does ~joe/.qmail exist? No.
                Write message to ./Mailbox in mbox format.




mail Local to Remote :
PIC.local2rem

Qmail Flow Diagram

                Original message:

                   To: bill@irs.gov
                   Hi.

qmail-inject    Fill in the complete envelope and header:

     |             (envelope) from joe@heaven.af.mil to bill@irs.gov
     |             From: joe@heaven.af.mil
     |             To: bill@irs.gov
     |
     |             Hi.
     V

qmail-queue     Store message safely on disk.
                Trigger qmail-send.
     |
     V

qmail-send      Look at envelope recipient, bill@irs.gov.
     |          Is irs.gov in locals? No.
     |          Is bill@irs.gov in virtualdomains? No.
     |          Is irs.gov in virtualdomains? No.
     |          Is .gov in virtualdomains? No.
     |          Deliver remotely to bill@irs.gov.
     V

qmail-rspawn    Run qmail-remote.

     |
     V

qmail-remote    Look at host name, irs.gov.
                Is irs.gov listed in smtproutes? No.
                Look up DNS MX/A for irs.gov and connect to it by SMTP:

                   MAIL FROM:<joe@heaven.af.mil>
                   RCPT TO:<bill@irs.gov>



Mail Local to Local Delivery :               

                   To: fred
                   Hi.

qmail-inject    Fill in the complete envelope and header:

     |             (envelope) from joe@heaven.af.mil to fred@heaven.af.mil
     |             From: joe@heaven.af.mil
     |             To: fred@heaven.af.mil
     |
     |             Hi.
     V

qmail-queue     Store message safely on disk.
                Trigger qmail-send.
     |
     V

qmail-send      Look at envelope recipient, fred@heaven.af.mil.
     |          Is heaven.af.mil in locals? Yes.
     |          Deliver locally to fred@heaven.af.mil.
     V

qmail-lspawn ./Mailbox

     |          Look at mailbox name, fred.
     |          Is fred listed in qmail-users? No.
     |          Is there a fred account? Yes.
     |          Is fred's uid nonzero? Yes.
     |          Is ~fred visible to the qmailp user? Yes.
     |          Is ~fred owned by fred? Yes.
     |          Give control of the message to fred.
     |          Run qmail-local.
     V

qmail-local fred ~fred fred '' '' heaven.af.mil joe@heaven.af.mil ./Mailbox

                Does ~fred/.qmail exist? No.
                Write message to ./Mailbox in mbox format.


Local to alias delivery :
Original message:

                   To: help
                   Hi.

qmail-inject    Fill in the complete envelope and header:

     |             (envelope) from joe@heaven.af.mil to help@heaven.af.mil
     |             From: joe@heaven.af.mil
     |             To: help@heaven.af.mil
     |
     |             Hi.
     V

qmail-queue     Store message safely on disk.
                Trigger qmail-send.
     |
     V

qmail-send      Look at envelope recipient, help@heaven.af.mil.
     |          Is heaven.af.mil in locals? Yes.
     |          Deliver locally to help@heaven.af.mil.
     V

qmail-lspawn ./Mailbox

     |          Look at mailbox name, help.
     |          Is help listed in qmail-users? No.
     |          Is there a help account? No.
     |          Give control of the message to alias.
     |          Run qmail-local.
     V

qmail-local alias ~alias help - help heaven.af.mil joe@heaven.af.mil ./Mailbox

                Does ~alias/.qmail-help exist? Yes: "john".
                Forward message to john.
Title: Re: Email processing - how do all the components work together?
Post by: Jean-Philippe Pialasse on November 30, 2021, 01:31:59 PM
(s)qpsmtpd  takes the place of qmail-smtpd

also with qmail installed a wrapper replace  sendmail to send it through qmail.

dkim signature is added at qpsmtpd level.  you see there a files issue that any email sent using sendmail (eg php) is not signed unless you use the sendmail-wrapper contrib or you configure your app to use smtp in place of semdmail
Title: Re: Email processing - how do all the components work together?
Post by: ReetP on November 30, 2021, 05:22:03 PM
Also note comments here:

https://en.wikipedia.org/wiki/Qmail

https://en.wikipedia.org/wiki/Qpsmtpd