I need to be able send web-mail and send to local admin with an attachment. I’v done some research and found various commands.
mail
mailx
sendmail
…
Which one(s) are common to distros and allow both local and webmail? Preferred, no additional installs and no system cfg setup? Please show recommended formatting based on following code.
Current line (not tested):
cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$VirusFoundZipSendEmailSubject"
**erlangen:~ #** readlink -f /usr/bin/mail
/usr/bin/mailx
**erlangen:~ #** rpm -qf /usr/bin/mailx
mailx-12.5-32.2.x86_64
**erlangen:~ #** zypper if mailx
Loading repository data...
Reading installed packages...
Information for package mailx:
------------------------------
Repository : Haupt-Repository (OSS)
Name : mailx
Version : 12.5-32.2
Arch : x86_64
Vendor : openSUSE
Installed Size : 576.5 KiB
Installed : Yes
Status : up-to-date
Source package : mailx-12.5-32.2.src
Summary : A MIME-Capable Implementation of the mailx Command
Description :
Nail is a mail user agent derived from Berkeley Mail 8.1. It is
intended to provide the functionality of the POSIX.2 mailx command with
additional support for MIME messages, POP3, and SMTP. In recent system
environments, nail is Unicode/UTF-8 capable. Further, it contains some
minor enhancements like the ability to set a "From:" address.
**erlangen:~ #**
**erlangen:~ #** zypper if postfix
Loading repository data...
Reading installed packages...
Information for package postfix:
--------------------------------
Repository : Haupt-Repository (OSS)
Name : postfix
Version : 3.6.2-7.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 3.4 MiB
Installed : Yes
Status : up-to-date
Source package : postfix-3.6.2-7.3.src
Summary : A fast, secure, and flexible mailer
Description :
Postfix aims to be an alternative to the widely-used sendmail program.
**erlangen:~ #**
Configuring postfix using “yast2 mail” takes a few minutes at most. But that is not an option for users who want to tinker.
Mail Delivery Status Report

Von: Mail Delivery System <MAILER-DAEMON@localhost>
An: Ich
Datum: 24.01.22 07:24
This is the mail system at host localhost.
Enclosed is the mail delivery report that you requested.
The mail system
<karl.mistelberger@....>: delivery via
mail.mnet-online.de[62.245.150.229]:25: 250 2.0.0 from
MTA(smtp:[frontend01.mail.intern.m-online.net]:10025): 250 2.0.0 Ok: queued
as 4Jj0MW4kDcz1qqkB
Unbenannt
Delivery report
Return-Path: <karl.....>
Received: by localhost (Postfix, from userid 1000)
id B8D16542DC; Mon, 24 Jan 2022 07:24:54 +0100 (CET)
Date: Mon, 24 Jan 2022 07:24:54 +0100
From: karl.....
To: karl....
Subject: test
Message-ID: <61ee4636.SbdEG3d6UXRw6TUg%karl.....>
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
______________________________________________________________________________
Sending Email...
Mail Delivery Status Report will be mailed to <username@server.com>.
**#** zypper if postfix
Loading repository data...
Reading installed packages...
Information for package postfix:
--------------------------------
Repository : Update repository with updates from SUSE Linux Enterprise 15
Name : postfix
Version : 3.5.9-5.9.2
Arch : x86_64
Vendor : SUSE LLC <https://www.suse.com/>
Installed Size : 3.2 MiB
Installed : Yes (automatically)
Status : up-to-date
Source package : postfix-3.5.9-5.9.2.src
Summary : A fast, secure, and flexible mailer
Description :
Postfix aims to be an alternative to the widely-used sendmail program.
The script has to setup everything in the code. I have many different auto-setup sections for many items. If postfix is needed to use mailx, I need to make a cross linux distros auto-setup.
**#** mail
No mail for root
**localhost:~ #** date | mail -s test root
**localhost:~ #** mail
Heirloom mailx version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@localhost Mon Jan 24 22:14 18/539 test
? 1
Message 1:
From root@localhost Mon Jan 24 22:14:41 2022
X-Original-To: root
Delivered-To: root@localhost
Date: Mon, 24 Jan 2022 22:14:41 -0800
To: root@localhost
Subject: test
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: root <root@localhost>
Mon Jan 24 22:14:41 PST 2022
? d
? 1
1: Inappropriate message
? quit
PS, the code is setup to send webmail not local mail. It will be another option I will add later, last one. Based on the above, I should be able to mail to local user with an attachment, for sending to admins.
format line:
scanvirus -sv f 1 home/username
scanvirus -sv m 1 username@server.com
scanvirus -sv e 1 root
(‘-sv l’ is list users).
# mail
No mail for root
localhost:~ # date | mail -s test -r username@server.com username@server.com
localhost:~ # mail
No mail for root
localhost:~ # date | mail -v -s test -r username@server.com username@server.com
Mail Delivery Status Report will be mailed to <username@server.com>.
No error output and no emails, 5 checks over 5 mins. ?? No debug info.
Web search ‘linux command line mail log’, nothing useful.
The delivery status email wasn’t going through. So, I changed the line to this.
cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -v -r root -s "$VirusFoundZipSendEmailSubject" "$Zip_Send_Email"
Message 1:
From MAILER-DAEMON Tue Jan 25 16:18:49 2022
X-Original-To: root@localhost
Delivered-To: root@localhost
Date: Tue, 25 Jan 2022 16:18:49 -0800 (PST)
From: MAILER-DAEMON@localhost (Mail Delivery System)
Subject: Mail Delivery Status Report
To: root@localhost
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="E73A444306.1643156329/localhost"
Content-Transfer-Encoding: 8bit
Part 1:
Content-Description: Notification
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
This is the mail system at host localhost.
Enclosed is the mail delivery report that you requested.
The mail system
<username@server.com>: connect to
mailsec.protonmail.ch[176.119.200.129]:25: Connection timed out
I had that email active and ready to receive. I sent an email to my old yahoo account same results.
From MAILER-DAEMON@localhost Tue Jan 25 08:12:27 2022
Return-Path: <>
X-Original-To: karl@localhost
Delivered-To: karl@localhost
Received: from erlangen.fritz.box (localhost [IPv6:::1])
by localhost (Postfix) with ESMTP id C9AF35668B
for <karl@localhost>; Tue, 25 Jan 2022 09:13:10 +0100 (CET)
Delivered-To: m10000*****
Received: from imap.mnet-online.de [2001:a60::143:1]
by erlangen.fritz.box with IMAP (fetchmail-6.4.26)
for <karl@localhost> (single-drop); Tue, 25 Jan 2022 09:13:10 +0100 (CET)
Received: from frontend02 ([127.0.0.1])
by backend02-a.mail.m-online.net with LMTP id 8GOpG+2w72G+dwAAyMk8yg
for <m1000075757>; Tue, 25 Jan 2022 09:12:29 +0100
Received: from mail.m-online.net ([127.0.0.1])
by frontend02 with LMTP id WPjLGu2w72GaTQAAz6fncw
; Tue, 25 Jan 2022 09:12:29 +0100
Received: from scanner-3.m-online.net (unknown [192.168.6.82])
by mail.m-online.net (Postfix) with ESMTP id 4Jjfj92RBvz1qqkC
for <karl@somewhere>; Tue, 25 Jan 2022 09:12:29 +0100 (CET)
X-Virus-Scanned: by amavisd-new at mnet-online.de
Received: from mxin-1.m-online.net ([192.168.6.165])
by scanner-3.m-online.net (scanner-3.mail.m-online.net [192.168.6.82]) (amavisd-new, port 10026)
with ESMTP id 8AWMg8kRIWv8 for <karl@somewhere>;
Tue, 25 Jan 2022 09:12:28 +0100 (CET)
Received: from bounces.m-online.net (bounces.m-online.net [212.114.242.6])
by mxin-1.m-online.net (Postfix) with ESMTP id 4Jjfj84hzLzvPsX
for <karl@somewhere>; Tue, 25 Jan 2022 09:12:28 +0100 (CET)
Received: from frontend01.mail.m-online.net (unknown [192.168.8.182])
by bounces.m-online.net (Postfix) with ESMTP id 4Jjfj84RmSz1qqkg
for <karl@somewhere>; Tue, 25 Jan 2022 09:12:28 +0100 (CET)
Received: from localhost (dynscan1.mnet-online.de [192.168.6.70])
by mail.m-online.net (Postfix) with ESMTP id 4Jjfj84DJpz1qqkH
for <karl@somewhere>; Tue, 25 Jan 2022 09:12:28 +0100 (CET)
Received: from mail.mnet-online.de ([192.168.8.182])
by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024)
with ESMTP id S2I_cq5evPKS for <karl@somewhere>;
Tue, 25 Jan 2022 09:12:27 +0100 (CET)
X-Auth-Info: Ty7VZyozO7aGLLfmDarsqMsEW3I/7XBFcZdqvORXlnsDNibDWDuGNHCugWHpQtNw
Received: from localhost (aftr-185-17-204-185.dynamic.mnet-online.de [185.17.204.185])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.mnet-online.de (Postfix) with ESMTPSA
for <karl@somewhere>; Tue, 25 Jan 2022 09:12:27 +0100 (CET)
Received: by localhost (Postfix)
id 8C42156689; Tue, 25 Jan 2022 09:12:27 +0100 (CET)
Date: Tue, 25 Jan 2022 09:12:27 +0100 (CET)
From: MAILER-DAEMON@localhost (Mail Delivery System)
Subject: Mail Delivery Status Report
To: karl@somewhere
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="A30AD56687.1643098347/localhost"
Content-Transfer-Encoding: 8bit
Message-Id: <20220125081227.8C42156689@localhost>
This is a MIME-encapsulated message.
--A30AD56687.1643098347/localhost
Content-Description: Notification
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
This is the mail system at host localhost.
Enclosed is the mail delivery report that you requested.
The mail system
<karl@somewhere>: delivery via
mail.mnet-online.de[62.245.150.229]:25: 250 2.0.0 from
MTA(smtp:[frontend01.mail.intern.m-online.net]:10025): 250 2.0.0 Ok: queued
as 4Jjfj73pWkz1qqkB
--A30AD56687.1643098347/localhost
Content-Description: Delivery report
Content-Type: message/delivery-status
Reporting-MTA: dns; localhost
X-Postfix-Queue-ID: A30AD56687
X-Postfix-Sender: rfc822; karl@somewhere
Arrival-Date: Tue, 25 Jan 2022 09:12:26 +0100 (CET)
Final-Recipient: rfc822; karl@somewhere
Original-Recipient: rfc822;karl@somewhere
Action: relayed
Status: 2.0.0
Remote-MTA: dns; mail.mnet-online.de
Diagnostic-Code: smtp; 250 2.0.0 from
MTA(smtp:[frontend01.mail.intern.m-online.net]:10025): 250 2.0.0 Ok: queued
as 4Jjfj73pWkz1qqkB
--A30AD56687.1643098347/localhost
Content-Description: Message Headers
Content-Type: text/rfc822-headers
Content-Transfer-Encoding: 8bit
Return-Path: <karl@somewhere>
Received: by localhost (Postfix, from userid 1000)
id A30AD56687; Tue, 25 Jan 2022 09:12:26 +0100 (CET)
Date: Tue, 25 Jan 2022 09:12:26 +0100
From: karl@somewhere
To: karl@somewhere
Subject: test
Message-ID: <61efb0ea.VpscK30h6hkEFfit%karl@somewhere>
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--A30AD56687.1643098347/localhost--
cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail v -s "$VirusFoundZipSendEmailSubject" -a "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -r "$Zip_Send_Email" -R "$Zip_Send_Email" "$Zip_Send_Email"
Nothing.
cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -v -s "$VirusFoundZipSendEmailSubject" -a "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -R "$Zip_Send_Email" -R "$Zip_Send_Email" "$Zip_Send_Email"
[FONT=monospace]**erlangen:~ #** journalctl --since 23:50 -u postfix.service
Jan 28 23:50:06 erlangen postfix/pickup[2746]: A93765B222: uid=1000 from=<fabian.maier@amberg-mail.de>
Jan 28 23:50:06 erlangen postfix/cleanup[4536]: A93765B222: message-id=<61f4731e.GsNQxpzJ6/ztbsQ8%fabian.maier@amberg-mail.de>
Jan 28 23:50:06 erlangen postfix/qmgr[1041]: A93765B222: from=<fabian.maier@amberg-mail.de>, size=466, nrcpt=1 (queue active)
Jan 28 23:50:07 erlangen postfix/smtp[4538]: A93765B222: to=<fabian.maier@amberg-mail.de>, relay=mail.mnet-online.de[62.245.150.229]:25, delay=0.89, delays=0.01/0.02/0.35/0.5, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[frontend01.mail.intern.m-online.net]:10025): 2>
Jan 28 23:50:07 erlangen postfix/qmgr[1041]: A93765B222: removed
Jan 28 23:50:56 erlangen postfix/smtpd[4620]: connect from localhost::1]
Jan 28 23:50:56 erlangen postfix/smtpd[4620]: C8D4A5B223: client=localhost::1]
Jan 28 23:50:56 erlangen postfix/cleanup[4536]: C8D4A5B223: message-id=<61f4731e.GsNQxpzJ6/ztbsQ8%fabian.maier@amberg-mail.de>
Jan 28 23:50:56 erlangen postfix/qmgr[1041]: C8D4A5B223: from=<fabian.maier@amberg-mail.de>, size=2937, nrcpt=1 (queue active)
Jan 28 23:50:56 erlangen postfix/local[4622]: C8D4A5B223: to=<karl@localhost>, relay=local, delay=0.05, delays=0.03/0.02/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Jan 28 23:50:56 erlangen postfix/qmgr[1041]: C8D4A5B223: removed
Jan 28 23:50:56 erlangen postfix/smtpd[4620]: disconnect from localhost::1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
**erlangen:~ #**[/FONT]
What are your messages?
Return-Path: <fabian.maier@amberg-mail.de>
X-Original-To: karl@localhost
Delivered-To: karl@localhost
Received: from erlangen.fritz.box (localhost [IPv6:::1])
by localhost (Postfix) with ESMTP id C8D4A5B223
for <karl@localhost>; Fri, 28 Jan 2022 23:50:56 +0100 (CET)
Delivered-To: m1000075757
Received: from imap.mnet-online.de [2001:a60::143:1]
by erlangen.fritz.box with IMAP (fetchmail-6.4.26)
for <karl@localhost> (single-drop); Fri, 28 Jan 2022 23:50:56 +0100 (CET)
Received: from frontend04 ([127.0.0.1])
by backend02-a.mail.m-online.net with LMTP id eAS0CyBz9GEdcgAAyMk8yg
for <m1000075757>; Fri, 28 Jan 2022 23:50:08 +0100
Received: from mail.m-online.net ([127.0.0.1])
by frontend04 with LMTP id 0JIPCyBz9GHkWQAA1Ru2Dg
; Fri, 28 Jan 2022 23:50:08 +0100
Received: from scanner-5.m-online.net (unknown [192.168.6.86])
by mail.m-online.net (Postfix) with ESMTP id 4Jlt2S1470z1qqkC
for <fabian.maier@amberg-mail.de>; Fri, 28 Jan 2022 23:50:08 +0100 (CET)
X-Virus-Scanned: by amavisd-new at mnet-online.de
Received: from mxin-1.m-online.net ([192.168.6.165])
by scanner-5.m-online.net (scanner-5.mail.m-online.net [192.168.6.86]) (amavisd-new, port 10026)
with ESMTP id 8A9dwx1eLMIM for <fabian.maier@amberg-mail.de>;
Fri, 28 Jan 2022 23:50:07 +0100 (CET)
Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10])
by mxin-1.m-online.net (Postfix) with ESMTPS id 4Jlt2R4PtWzvPsP
for <fabian.maier@amberg-mail.de>; Fri, 28 Jan 2022 23:50:07 +0100 (CET)
Received: from frontend01.mail.m-online.net (unknown [192.168.8.182])
by mail-out.m-online.net (Postfix) with ESMTP id 4Jlt2R3zt8z1sYfG
for <fabian.maier@amberg-mail.de>; Fri, 28 Jan 2022 23:50:07 +0100 (CET)
Received: from localhost (dynscan1.mnet-online.de [192.168.6.70])
by mail.m-online.net (Postfix) with ESMTP id 4Jlt2R3tV7z1qqkB
for <fabian.maier@amberg-mail.de>; Fri, 28 Jan 2022 23:50:07 +0100 (CET)
Received: from mail.mnet-online.de ([192.168.8.182])
by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024)
with ESMTP id IVbJJAfev3u2 for <fabian.maier@amberg-mail.de>;
Fri, 28 Jan 2022 23:50:07 +0100 (CET)
X-Auth-Info: seW5UqTCJJlxmgLl9+Tp/6X9dttWyLE2qLmmg36hX9CQ7kk5Qd1fE7ezEt2ZCeHL
Received: from localhost (aftr-185-17-204-200.dynamic.mnet-online.de [185.17.204.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.mnet-online.de (Postfix) with ESMTPSA
for <fabian.maier@amberg-mail.de>; Fri, 28 Jan 2022 23:50:07 +0100 (CET)
Received: by localhost (Postfix, from userid 1000)
id A93765B222; Fri, 28 Jan 2022 23:50:06 +0100 (CET)
Date: Fri, 28 Jan 2022 23:50:06 +0100
From: fabian.maier@amberg-mail.de
To: fabian.maier@amberg-mail.de
Subject: test
Message-ID: <61f4731e.GsNQxpzJ6/ztbsQ8%fabian.maier@amberg-mail.de>
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -v -s "$VirusFoundZipSendEmailSubject" -a "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -R "$Zip_Send_Email" "$Zip_Send_Email"
Sending Email...
Mail Delivery Status Report will be mailed to <root>.
#mail
?1
Message 1:
From MAILER-DAEMON Fri Jan 28 16:24:17 2022
X-Original-To: root@localhost
Delivered-To: root@localhost
Date: Fri, 28 Jan 2022 16:24:17 -0800 (PST)
From: MAILER-DAEMON@localhost (Mail Delivery System)
Subject: Delayed Mail (still being retried)
To: root@localhost
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="2768646F2D.1643415857/localhost"
Content-Transfer-Encoding: 8bit
Part 1:
Content-Description: Notification
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
This is the mail system at host localhost.
####################################################################
# THIS IS A WARNING ONLY. YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
####################################################################
Your message could not be delivered for more than 1 hour(s).
It will be retried until it is 5 day(s) old.