BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sonofendor
Fluorite | Level 6

Hello everyone!

 

I want to send an email from our SAS server. I tried to do it like it's written in documentation:

filename myemail EMAIL
  to=/*here is my personal email*/
  subject="Testing email connection";

data _null_;
	file	myemail;
	put	'Test...';
run;

I got the error "ERROR: Email: The connection was refused."

Then I read this and tried to send an email from my own gmail mailbox:

options emailhost=
 (
   "smtp.gmail.com" 
   port=587 STARTTLS 
   auth=plain 
   id=/*my email*/
   pw=/*my password*/
 )
;

I got other error "ERROR: Unable to create cipher."

The default email options are:

 EMAILACKWAIT=30  
 EMAILAUTHPROTOCOL=NONE
 NOEMAILFROM      
 EMAILHOST=/* our hostname */
 EMAILID=          
 EMAILPORT=25      
 EMAILPW=XXXXXXXX  
 EMAILUTCOFFSET=   
 EMAILSYS=SMTP 

How do I send emails from SAS code? Or how do I check if it's even possible on our server?

 

Thank you for your replies

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

Your first set of code should work.  You might have to talk to your email administration team.  The "Connection Refused" message sounds like a setting that your company has put in place.

 

The second set of code might be blocked by a firewall, I'm not sure. I doubt most companies would leave the ports open, but it depends on your company.

 

Jim

View solution in original post

8 REPLIES 8
Sajid01
Meteorite | Level 14

1. Your first code should work. What environment (your SAS install) are you using.
I tested with SAS OnDemand for Academics and it works flawlessly.
2.About using Gmail, access to less secure apps needs to be enabled in gmail.
This information is available in your reference.

sonofendor
Fluorite | Level 6

I'm running the code from SAS Data Integration Studio 4.904. Sas version is 9.4 and the platform is Linux 3.10.0-957.21.3.el7.x86_64 (LIN X64). Also I tried to do it from SAS EG 8.1 but got the same "Connection refused" error. So I guess the deal is with server options.

 

Can you please provide me with your proc options group=email output? 

jimbarbour
Meteorite | Level 14

Your first set of code should work.  You might have to talk to your email administration team.  The "Connection Refused" message sounds like a setting that your company has put in place.

 

The second set of code might be blocked by a firewall, I'm not sure. I doubt most companies would leave the ports open, but it depends on your company.

 

Jim

Sajid01
Meteorite | Level 14

Hello @sonofendor 
Please have a look at this https://support.sas.com/kb/19/767.html.. This guides about the SAS side including the options. These are typically set when the SAS server is installed.
It is possible that your organization has a policy that regulates email services. Do check with your administrators.

 

SASKiwi
PROC Star

Check with your SAS administrator for the correct settings in your code. He/she should know this. If you already using the right approach, then he/she should be able to sort problems with port firewall rules etc. 

DavePrinsloo
Pyrite | Level 9
You can only send mail if the SAS system administrator has set up and authorized email capabilities for you. This will be done by adjusting the firewall to allow connection to the emailport (25) on the email host from the SAS server. Connection refused generally means that one of the email settings is incorrect, or the firewall is blocking the connection.
sonofendor
Fluorite | Level 6

Thank you all for you replies! So I have talked with administrators and it turned out that they don't want to allow sending emails from our server 😁 Once again thanks to everyone for the replies!

SASKiwi
PROC Star

Please mark your post as answered then.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 4447 views
  • 9 likes
  • 5 in conversation