matthijs wrote:Does anyone by any chance has a good bookmark for some reading about this sendmail/smtp stuff? I mean not the "hello world this is my first mail" stuff, but some background on how sendmail and smtp works, what positive and negative things are, which to choose when, etc. I'm still having problems getting email send (with swiftmailer), so I would like to delve into it a bit. Thanks!
I'll try to explain as best I can.
MTA = Mail Transfer Agent
SMTP = Simple Mail Transfer Protocol
SMTP servers are backed by an MTA. In other words, they listen on a certain port (25) and when they get requests they pass them onto the MTA.
SMTP, being a protocol is basically a language for one computer to talk to another.
Computer A wants to send an email.
Computer B is running an SMTP server.
So computer A connects to computer B and says "Hello" almost literally by going "HELO".
Computer B then responds by saying OK and "HELO" again before idnetifying it's capabilities.
Computer A then continues to ask computer B to do things and computer B keeps telling computer A how well it did them.
The general process for sending an email over SMTP would be:
Computer A says HELO
Computer B says OK and HELO
Computer A says it wants to send a mail from some@address
Computer B says yeah fine whatever
Computer A says it want to send this mail to some@address
Computer B says yeah go ahead then, give me the email and I'll send it for you
Computer A then passes the email to computer B
Computer B says thanks I've done that for you, you can either go now or I'll do something else for you.
Now, obviously all of the uses bandwidth and takes time while the two machines talk to each other like this. Using sendmail we can do the same sort of thing but we don't need to bother asking another computer to get invloved immediately. Computer A open sendmail (a program on the machine itself) and tells it what it would tell an SMTP server (no bandwidth uses yet). Sendmail then sticks the message in a queue and does the SMTP stuff when it gets a chance.
From your own point of view, you want to use sendmail if you have it installed (only works on linux) since there is no TCP data being sent whilst the PHP script runs so the whole thing finishes quicker. You also pass the responsibility away from PHP and just let sendmail deal with Computer B by itself.
Actual sequence of commands:
HELO myname.tld <--- This is me saying Hi!
250 w3style.co.uk Hello name.tld [213.205.138.XXX] <--- This is the server saying Hi
MAIL FROM:
me@address.com <-- Thi is me asking to send an email
250 OK <-- This is the server saying OK
RCPT TO:
chris@w3style.co.uk <-- This is me saying I want the mail to go to this address
250 Accepted <-- Server says OK
DATA <-- Me saying I'm going to give it the email now
354 Enter message, ending with "." on a line by itself <-- Server just being helpful
This is where the email goes <-- My message
.
250 OK id=1G0hKJ-0004JL-LE <-- Server saying yeah sent ok