Shell Send an email from sh(1) via SMTP

I'm playing with mailpit and need something quick and easy to send test emails to port 1025 on localhost.

I tried mutt but that goes to a local mailbox. Just looking for ideas.
 
If you're using emacs
Code:
(setq send-mail-function #'smtpmail-send-it)
(setq smtpmail-smtp-server "localhost")
(setq smtpmail-smtp-service 1025)
M-x mail
Code:
From: ab
To: cd
Subject: ef
--text follows this line--
gh
M-x mail-send-and-exit
 
I found how to point dma to an external SMTP server (which happens to be localhost in this case). I honestly thought dma ran as a daemon. It only runs when there is mail to deliver. Sending to an external address causes dma to forward to the server in /etc/dma/dma.conf. This did not even require an /etc/dma/auth.conf file.

Two lines edited in /etc/dma/dma.conf:
SMARTHOST localhost
PORT 1025


NOW I can send mail to mailpit using mutt or mail and view the results in a browser on http://localhost:8025/

 
Last edited:
I'm playing with mailpit and need something quick and easy to send test emails to port 1025 on localhost.

I tried mutt but that goes to a local mailbox. Just looking for ideas.
Some MUAs send mail by piping to sendmail, similar to, some_app | sendmail -Bs. Others drop email to some server : port, such as claws-mail. It depends on what you might wan to do.

If you want to really get into the weeds you nc (netcat) or telnet to port 1025 and type in the the SMTP commands yourself. Or write a shell script to do this for you. Better yet, Perl and python supply modules that do this for you, allowing you to script to your hearts content.

Personally, I'd opt to use some Perl or python module. Done that before.

Not only that, once you get the hang of using python modules -- I recommend python over perl, perl is antiquated and quirky -- you'll start using the REST API module to interface with websites. I and my team just built a REST API interface between Ansible Automation Platform and ServiceNow. It's an exciting new world of modules and APIs out there.

If perl or python aren't your thing, you could use the ansble mail module. Used that too. It works quite well.

If you're testing, do it properly and write a script to perform the test for you. It's reproducible and so much quicker to run when you need to. There are a lot of ways to script this.
 
Back
Top