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  Zimbra Stuck Open Webmail - Zimbra Unable to index

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.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

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

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