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
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
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.
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?
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
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.
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.
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!
Please mark your post as answered then.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.