Can anyone tell me if it is possible to send an e-mail directly to the outside world, just like an SMTP server would (and what it might involve)? I know I can use javamail and an external SMTP server, or host my own, but I don’t get why I can’t send the e-mails directly without the SMTP server middle-man.
My basic idea is to embed a lightweight component in an application server and remove the need for an independant SMTP server and associated database. Ideally, I’d like to reuse the communications layer of an existing java project and put my implementation behind it to send message, receive messages and, I imagine, handle errors.
Any help appreciated!
It is certainly possible to implement the SMTP spec on the client side. It would involve DNS calls to locate the proper MX record for the recipient’s domain, connecting to the recipient’s SMTP server on the proper port, and implementing the SMTP protocol to actually send the mail.
As spam has assumed an increasingly large role in email, doing the above has become much, much more difficult. Mail servers are very picky about exactly what kinds of mail and headers they will and won’t accept, and if you don’t behave exactly as a "real" SMTP server would your mail almost certainly will not go through.