Pivotal Knowledge Base

Follow

HowTo - Send emails from scripts

Environment

Pivotal DCAv1 and DCAv2.

Goal

In this article we will take a look on how to send emails from scripts? 

Solution

-- 1. Contact your account manager and submit an RPQ (Request for Product Qualification) to use mailx / sendmail on your DCA.

-- 2. Once the RPQ is approved, install any RPM packages required to get both mailx and sendmail on the system. You need these packages and any pre-requisites:

  • sendmail
  • sendmail-cf
  • mailx

Package files can be found in /opt/rhel/55/CD1/Server.

-- 3. Next, update the configuration. In this example we update it on the master host mdw.

3.1 Look for this line in sendmail configuration: dnl define(`SMART_HOST', `smtp.your.provider')dnl

[root@mdw ~]# vi /etc/mail/sendmail.mc

Uncomment it by removing the "dnl" strings and replace with your SMTP host, for example:

define(`SMART_HOST', `smtp.example.com')

Then add a line for the external domain name of your host

define(`confDOMAIN_NAME', `yourmaster-extname.example.com')

3.2 Edit or add that host name to /etc/hosts. For example, if you have:

1.2.3.4 mdw-ext

That should become:

1.2.3.4 mdw-ext yourmaster-extname.example.com

3.3 Then rebuild the configuration

[root@mdw ~]# make -C /etc/mail
make: Entering directory `/etc/mail'
make: Leaving directory `/etc/mail'
[root@mdw ~]#

3.4 Make sure sendmail is started

[root@mdw ~]# chkconfig sendmail on
[root@mdw ~]# service sendmail start
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]
[root@mdw ~]#

-- 4. Test mailx to send emails

cat email.txt | mailx -s "Subject line" recipient@example.com

Comments

Powered by Zendesk