Pivotal Knowledge Base


HowTo - Send emails from scripts


Pivotal DCAv1 and DCAv2.


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


-- 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: mdw-ext

That should become: 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


Powered by Zendesk