habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Send Email with Command Line Terminal CLI Using Zimbra

1 min read

Sending Mail via Command Line Terminal CLI Using Zimbra

Sometimes as an Administrator meet conditions need sending an email via CLI, for example to send backup status, notification of server conditions and others. As a Zimbra Mail Administrator, we need send email with command line use zimbra engine for sending. Overwrite sendmail that used transport by default.

In fact even though we have already installed zimbra and running well, and when want to send email from the command line, the mail engine transport not use zimbra. By default using sendmail and the path already exists. Therefore, in this article we will modify the sendmail/mta path so that it can use the zimbra engine as Mail Transport.

Install Mailx for send email command zimbra

For this purpose we can use the mailx application which can be installed with the following command:

yum install mailx

As describe above, by default the mail command will use the sendmail CLI to send email. So we must change or modify that the mail command uses the zimbra engine. Here is command that run in zimbra 8.8.12.

rm /etc/alternatives/mta
rm /usr/sbin/sendmail
rm /usr/lib/sendmail

ln -s /opt/zimbra/common/sbin/sendmail /etc/alternatives/mta
ln -s /etc/alternatives/mta /usr/sbin/sendmail
ln -s /etc/alternatives/mta /usr/lib/sendmail

Note: for zimbra version 8.60 earlier, please replace :

/opt/zimbra/common/sbin/sendmail

to

/opt/zimbra/postfix/sbin/sendmail

Test Send Email via CLI

Then test running the mail command:

mail -a /tmp/verbose.txt -s 'Test Email mydomain.com at' $ DATE '' [email protected]
  • -a : Add attachment parameter, followed path of file that will be attach.
  • -s : Subject of mail that will be send.
  • [email protected]: receiver of mail.
See also  How to Setting IP Static Ubuntu 18 or 20.04

The above command will send an email with the subject “Test Email mydomain.com at (date current)” to email [email protected] with the contents of the e-mail taken from the file /tmp/verbose.txt.

Cheers.


habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox