SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
texasmfp
Lapis Lazuli | Level 10

I have spent days pouring over every note, paper. SAS documentation and even watched the Chris Hemdinger video.  I simply cannot get SAS to send an email.

 

After troubleshooting and trying every combination of SAS email system option (and getting error messages galore) I think this has nothing to do with the data step and everything to do with the email host option.  Unfortunately, every guide, every Communities note, etc basically says either "we assume you know how to set up your smtp mail server" or, contact your admin to get your smtp email server. 

 

I am the admin, this is a personal computer, not a work computer and I have no idea what a smtp email server is. 

 

To send and email, I open Firefox, open gmail, log in.

 

When I first tried sending an email in SAS, I got a message saying no email is associated....

 

So, I did something I had never done and that was to go to Windows and associate MAIL.  I first associated with Firefox, then I tried with Chrome, finally with the Windows 10 recommended MAIL, which apparently opens something called Outlook.  In Outlook, I linked several email accounts and one by one tried sending email in SAS.

 

I have also tried all, and I mean all, of the various SAS system email options/settings in every paper, tip, documentation for each email account, for each smtp association.

 

I have received a dozen different EMAIL Error messages.  Can anybody help me troubleshoot?  And yes, I know and submit

 

proc options group=email;
run;
with every attempt

 

Thanks

9 REPLIES 9
Kurt_Bremser
Super User

See here first:

https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/038-2008.pdf 

 

By using EMAILSYS=MAPI, you can use your local mail client (e.g. Outlook).

 

To use SMTP, you need to get the settings for SMTP from your mail client and configure those into SAS. Or get such settings from elsewhere (in a company or other organization, the mail admin).

 

Using Firefox with gmail means that in fact nothing mail-specific happens on your computer, everything happens in a web app running on the Google servers. So that path can't be used from inside SAS code.

texasmfp
Lapis Lazuli | Level 10

Thanks Kurt, but when I set it to MAPI, I get:

 

ERROR: Undetermined I/O failure

 

Oh and how do I find out what my local email client is?

texasmfp
Lapis Lazuli | Level 10

Thanks again, Kurt.  I do not think bitness is the issue as I just installed Mozilla Thunderbird for Windows 64 as, what I hope is, my email client.  I am using 64-bit install of SAS 9.4 TS1M6.

 

I was still ignorant in my earlier post and I misspoke.  I pointed Windows to the Windows Mail app and, had linked 3 email accounts (hotmail, gmail, and an outlook account).  Outlook was never my email client.  I was apparently looking at an Outlook account when I said, in my ignorance, that I had installed Outlook.

 

That said, the new error message with the Thunderbird email client:

 

ERROR: Email: 550 No SMTP server defined. Use real server address instead of 127.0.0.1 in your account.

 

I have no idea what a "real" server address is, let alone whatever SAS thinks 127.0.0.1  is.

 

I am using these SAS options with the Thunderbird app as per the app's references:

 

texasmfp_0-1645876474529.png

 

options EMAILSYS=smtp;
options emailhost=imap.gmail.com;

 

but have also tried:

options EMAILSYS=mapi;
options emailhost=smtp.gmail.com;

 

options EMAILSYS=mapi;
options emailhost=imap.gmail.com;

 

not that I know what any of that means

 

but gives me

 

ERROR: Login failure and a new one

 

ERROR: Email: The software caused the connection to abort.

 

apparently there is also something called an outgoing server and an incoming server, which is slightly different.  Again, bit of a Luddite and no clue what these mean to SAS.

Kurt_Bremser
Super User

To send email (not to retrieve email from a server, which uses IMAP or POP3), all applications use the Simple Mail Transfer Protocol. This must be configured to access a server that takes over handling the mail. Mail clients like Outlook support you in doing that (servernames, ports), but you need a valid mail account for that (e.g. your gmail account).

I suggest that you first set up mail from your PC so that you can send mails from there, and then replicate the SMTP configuration in SAS.

Sajid01
Meteorite | Level 14

Hello @texasmfp 

As I see it ,there are two scenarios of sending emails using SAS which I have come across.

(There may be other use case but I haven't used them ).

1.Scenarion 1:

To send email from SAS one does need an SMTP server (A server process/ daemon that sends and receives email). In corporate environment generally they have an SMTP server and and the SAS Server has this information configured. Alternatively the SMTP details can be included in your program. As you have researched sending email by SAS you must be having the necessary  details. (For those who don't please see SAS documentation of google it). Email can be sent from SAS running on the Desktop or Server.

2.Scenario 2: SAS installed on a personal desktop and no access to own SMTP server.

As I infer from your post, this case applies.
You can use use your google account following the process mentioned in this blog https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/)

Unless there is a very specific need, it is simpler and easier to use email  clients like Thunderbird / Outlook etc. in this scenario.

texasmfp
Lapis Lazuli | Level 10

I finally got it to work.  This really had nothing to do with SAS and everything to do with setting up an email client, rebooting a few times, and getting the SAS EMAIL System Options set.  The last step was to go into Gmail, locate a very hard to find part of the account settings and enabling 3rd party access to less secure apps.  Unfortunately, I saw this message, which suggest that my newfound email ability will go away at the end of May.  Looking for alternatives.

 

texasmfp_0-1645931755922.png

 

ChrisHemedinger
Community Manager

To continue this working, you might need to use the "App password" mechanism. I believe that you first have to enable 2-factor auth on your Google account (a best practice). From my blog post:

 

If you use two-factor authentication on your Google account (a best practice), then you will need to takean additional step and create an "App password"-- which will allow a third-party app to use Gmail on your behalf and bypass the verification step. As always, your Google password and any App password you generate should be managed carefully and secured.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 9 replies
  • 3389 views
  • 5 likes
  • 4 in conversation