Proxmox Virtual Environment (VE) 7.1-8 – installing sSMTP is a simple MTA to deliver mail from a computer to a mail hub (SMTP server) on Debian 11 (Bullseye) Server

sSMTP is a program which delivers email from a local computer to a configured mailhost (mailhub) it is not a mail server (like feature-rich mail server sendmail) and does not receive mail expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address

root@pve-iot-jsho-mail-01:~# apt-get update -y
root@pve-iot-jsho-mail-01:~# apt-get full-upgrade -y
root@pve-iot-jsho-mail-01:~# apt-get install ssmtp mailutils
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
mailutils is already the newest version (1:3.10-3+b1).
ssmtp is already the newest version (2.64-10).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@pve-iot-jsho-mail-01:~#
root@pve-iot-jsho-mail-01:~# vi /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=josef.schuster@dpsolution.de
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.1und1.com:587
# Where will the mail seem to come from?
rewriteDomain=dpsolution.de
# The full hostname
hostname=pve-iot-jsho-mail-01.fritz.box
# Are users allowed to set their own From: address?
# YES – Allow the user to specify their own From: address
# NO – Use the system generated From: address
FromLineOverride=YES
AuthUser=josef.schuster@dpsolution.de
AuthPass=<password>
UserSTARTTLS=YES
root@pve-iot-jsho-mail-01:~# vi /etc/ssmtp/revaliases
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:josef.schuster@dpsolution.de:smtp.1und1.de:587
root@pve-iot-jsho-mail-01:~#
root@pve-iot-jsho-mail-01:~# ssmtp -v josef.schuster@dpsolution.de
<Mail Text>[STRG]+[D]
[<-] 220 kundenserver.de (mreue107) Nemesis ESMTP Service ready
[->] EHLO pve-iot-jsho-mail-01.fritz.box
[<-] 250 STARTTLS
[->] AUTH LOGIN
[<-] 334 VXNlcm5hbWU6
[->] am9zZWYuc2NodXN0ZXJAZHBzb2x1dGlvbi5kZQ==
[<-] 334 UGFzc3dvcmQ6
[<-] 235 Authentication succeeded
[->] MAIL FROM:<josef.schuster@dpsolution.de>
[<-] 250 Requested mail action okay, completed
[->] RCPT TO:<josef.schuster@dpsolution.de>
[<-] 250 OK
[->] DATA
[<-] 354 Start mail input; end with <CRLF>.<CRLF>
[->] Received: by pve-iot-jsho-mail-01.fritz.box (sSMTP sendmail emulation); Sun, 23 Jan 2022 12:04:08 +0000
[->] From: „root“ <josef.schuster@dpsolution.de>
[->] Date: Sun, 23 Jan 2022 12:04:08 +0000
[->]
[->] .
[<-] 250 Requested mail action okay, completed: id=1MLhwM-1mtwCE3Bbs-00Hhfi
[->] QUIT
[<-] 221 kundenserver.de Service closing transmission channel

root@pve-iot-jsho-mail-01:~#
root@pve-iot-jsho-mail-01:~# echo „Mail-Inhalt“ | mail -s „Betreff“ josef.schuster@dpsolution.de

root@pve-iot-jsho-mail-01:~# apt-get install mpack
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Suggested packages:
inews
The following NEW packages will be installed:
mpack
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 39.3 kB of archives.
After this operation, 109 kB of additional disk space will be used.
Get:1 http://ftp.debian.org/debian bullseye/main amd64 mpack amd64 1.6-17 [39.3 kB]
Fetched 39.3 kB in 5s (7726 B/s)
Selecting previously unselected package mpack.
(Reading database … 21473 files and directories currently installed.)
Preparing to unpack …/mpack_1.6-17_amd64.deb …
Unpacking mpack (1.6-17) …
Setting up mpack (1.6-17) …
Processing triggers for man-db (2.9.4-2) …
root@pve-iot-jsho-mail-01:~#
root@pve-iot-jsho-mail-01:~# ls -la
total 20
drwx—— 2 root root 4096 Jan 23 09:03 .
drwxr-xr-x 22 root root 4096 Jan 23 09:03 ..
-rw——- 1 root root 2266 Jan 23 11:04 .bash_history
-rw-r–r– 1 root root 571 Apr 10 2021 .bashrc
-rw-r–r– 1 root root 161 Jul 9 2019 .profile
root@pve-iot-jsho-mail-01:~# mpack -s „Test“ .profile josef.schuster@dpsolution.de
root@pve-iot-jsho-mail-01:~#

 

Change the ‚From‘ text by editing /etc/passwd to receive mail from ‚root at myhost‘ instead of just ‚root‘

chfn [-f full-name] [-o office] [-p office-phone] [-h home-phone] [-u] [-v] [username]

root@rpi-iot-jsho-mail-01:~# chfn -f ‚root at rpi-iot-jsho-mail-01.fritz.box‘ root

Which changes /etc/passwd to

root@rpi-iot-jsho-mail-01:~# cat /etc/passwd
root:x:0:0:root at rpi-iot-jsho-mail-01.fritz.box,,,:/root:/bin/bash
root@pve-iot-jsho-mail-01:~# mpack -s „Test“ .profile josef.schuster@dpsolution.de

Leave a Reply

You must be logged in to post a comment.