Using SAS® software to send SMTP email


Follow the steps in this SAS KB article to send SMTP email with SAS software.

Before beginning the steps, ensure that you have an SMTP email server that you can access.

Use an OPTIONS statement like the following:

options emailsys=smtp emailhost=your.smtpemail.server.com emailport=25;

In this statement, emailhost is the SMTP server specific to your site. Check with your email administrator to determine the correct SMTP email server name. Port 25 is the most common, but check with your email administrator to verify the correct value.

To reveal the status of the email options in the SAS log, submit the following:

proc options group=email;
run;

Alternatively, make the following edits to your config (SASv9.CFG) file:

-emailsys SMTP
-emailhost your.smtpemail.server.com
-emailport 25

You can determine the location of your config file by submitting the code below:

proc options option=config;
run;

The sample code below emails very simple text from a DATA _NULL_ step:

 filename mymail email "your.emailaddress.com_or_edu" subject="test message";
 data _null_;
    file mymail;
    put 'Hello there';
 run; 

When you use SMTP email, you are bypassing any local email client on your machine. SAS is sending email directly to the SMTP server. If you need to stop using SMTP email with SAS so that SAS can send email with your local email client (such as Lotus Notes or Outlook), remove or comment out the email options added to the configuration file used for SMTP.

For troubleshooting steps to follow when you cannot successfully send SMTP email from SAS, see SAS KB0036202 "Troubleshooting guidelines for successfully sending an SMTP e-mail from SAS® software."