(o o)
____________ooO_( )_Ooo_______________________________a_m_o_x___
____ __ __ _____ ____
___/ ___|| \/ |_ _| _ \
/ __\___ \| |\/| | | | | |_) |
\__ \___) | | | | | | | __/
|___/____/|_| |_| |_| |_|
Installation and Configuration
Sending Mails from Commandline
Today I installed 'sSMTP' on my VPS to have the ability to
send mails from commandline.
+---------------------------------------------------------+
| $ sudo apt install ssmtp |
+---------------------------------------------------------+
There are two config files to adapt:
/etc/ssmtp/ssmtp.conf
/etc/ssmtp/revaliases
I configured sSMTP to use it with my 'mailbox.org' mail account.
(See
https://mailbox.org/ for a privacy friedly mail account.)
+---------------------------------------------------------+
| $ sudo nano /etc/ssmtp/ssmtp.conf |
+---------------------------------------------------------+
| |
| hostname=mailbox.org |
| FromLineOverride=YES |
| UseSTARTTLS=YES |
| UseTLS=YES |
| mailhub=smtp.mailbox.org:587 |
|
[email protected] |
| AuthPass=mypassword |
+---------------------------------------------------------+
+---------------------------------------------------------+
| $ sudo nano /etc/ssmtp/revaliases |
+---------------------------------------------------------+
| |
| mylinuxuser:
[email protected] |
+---------------------------------------------------------+
The senders fullname ist the logged-in linux users fullname.
Take a look at /etc/passwd ...
+---------------------------------------------------------+
| $ cat /etc/passwd |
| |
| ... |
| mylinuxuser:x:1000:1000:My Fullname,,,:/home/... |
| ... |
+---------------------------------------------------------+
BTW, you can change the fullname with 'chfn'
+---------------------------------------------------------+
| $ sudo chfn -f "New Fullname" mylinuxuser |
+---------------------------------------------------------+
You can override the sender email and fullname during runtime by adding
FromLineOverride=YES
to your '/etc/ssmtp/ssmtp.conf' file.
When the configuration is done, a testmail can be sent:
+---------------------------------------------------------+
| $ echo "Subject: testmail" | ssmtp -vvv \ |
| -f "
[email protected]" -F "This is me" \ |
|
[email protected] |
+---------------------------------------------------------+
This sends a mail with the subject "testmail" and no more text to
[email protected].
-vvv turns on verbosity output
-f overrides the senders email address configured in
/etc/ssmtp/revaliases
-F overrides the senders fullname configured in
/etc/passwd
Sample -vvv verbose output:
[<-] 220 smtp2.mailbox.org ESMTP Postfix
[->] EHLO mailbox.org
[<-] 250 CHUNKING
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO mailbox.org
[<-] 250 CHUNKING
[->] AUTH LOGIN
[<-] 334 ************
[->] **************************==
[<-] 334 ************
[<-] 235 2.7.0 Authentication successful
[->] MAIL FROM:<
[email protected]>
[<-] 250 2.1.0 Ok
[->] RCPT TO:<
[email protected]>
[<-] 250 2.1.5 Ok
[->] DATA
[<-] 354 End data with <CR><LF>.<CR><LF>
[->] Received: by mailbox.org (sSMTP sendmail emulation); Mon, 28 Jun 2021 23:01:21 +0200
[->] From: "This is me" <
[email protected]>
[->] Date: Mon, 28 Jun 2021 23:01:21 +0200
[->] Subject: testmail
[->]
[->] .
[<-] 250 2.0.0 Ok: queued as *********
[->] QUIT
[<-] 221 2.0.0 Bye
You can also send mails with more text, attachments ...
___________________________________________________28_06_2021___