- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello SAS community,
I am attempting to send an email from a SAS program for the first time using the following method:
options emailsys=smtp emailhost=smtphost.domainx.com emailport=465 EMAILID="email@domainx.com" EMAILPW="password"; filename mymail email "recipient@domainy.com" subject="Test Message"; data _null_; file mymail; put 'Hello there'; run;
But, I encountered this error:
"ERROR: Email: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM."
I would like to know if there is something I need to add or modify in order to resolve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
1) emailauthprotocol= ?
2) is
EMAILID="email@domainx.com"
valid email address ?
[EDIT:]
3) maybe:
emailhost=(smtphost.domainx.com SSL)
if you have SSL there?
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
emailauthprotocol=plain
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SMTP Error 530 is an authentication issue. The most likely cause is that you provided invalid login credentials. I tried your code using my own SMTP server and credentials, and it ran without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This might depend on your email server setup and authentication. If you have single-signon or two-factor authentication (common in cloud-based email), then a simple password might not be enough to authenticate. See tips here (specific to Gmail) and see if you need to adapt accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ChrisHemedinger
Can you please let me know what information I should request from the person in charge of the SMTP server?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Actually, in reviewing the original error I think you should try adding the FROM= option to your code. See How to send email using SAS for simple examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tried the examples provided in the article, but I consistently encountered the same errors. but, when I tested sending a test email using the following command on the SAS compute server:
[sas@computeserver ~]$ swaks --to recipient@domainy.com --from email@domainx.com --server smtphost.domainx.com --tls --auth LOGIN --port 465
the email was successfully sent. I used the same credentials that I had previously used in the SAS program. I'm unsure what might be missing in the SAS program that prevented the email from being sent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Did you fix your SAS code to specify the FROM address?
Are you sure your SAS session is running on the same machine as your test? Using the same userid?
Also do any of the addresses contain special characters that might make generating them from SAS tricky?
Does your SAS session have XCMD option enabled? If so you could generate the email message first and then just call that same swaks command to send it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Did you fix your SAS code to specify the FROM address? Yes, but it didn't work.
Are you sure your SAS session is running on the same machine as your test? Yes, it is the same.
Also do any of the addresses contain special characters that might make generating them from SAS tricky? Yes, the FROM address is like this: username_ab@domainx.com .
you could generate the email message first and then just call that same swaks command to send it.
Could you please provide an example of how I can do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here a line from a 25 year old program:
*----------------------------------------------------------------------; * When not in drug project environment, send email to SPE admin. ; *----------------------------------------------------------------------; %let status = PENDING; %let s_msg = Project &drug_c waiting for SPE set up; x cat %gdir(gsys)scs_msg1.txt | mailx -s "SCS request &drug_c setup" -c &email -r cdoadm@pfizer.com &speadm;
So the message to be sent was already written to the text file scs_msg1.txt. Then the mailx command is called to send the message as an email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @Mahis
Please modify the following section of your code
filename mymail
email "recipient@domainy.com"
subject="Test Message";
to
filename mymail
to="recipient@domainy.com"
subject="Test Message";
It should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone, thank you all for your help. I was able to send an email using Tom's method of xcmd by adding the 'swaks' command in the script. However, I found that when I entered the password directly in the command, I got unsuccessful authentication because the password is decoded in base64 into a different password than what I typed. To avoid this issue, I used the following command to enter the password in this format:
$(echo 'cGFzc3dvcmR4' | base64 --decode)
This is the full command I used to send the email:
x "swaks --to &rec --from &sen --server &serv --tls --auth LOGIN --port 465 --auth-user userx1 --auth-password $(echo 'cGFzc3dvcmR4' | base64 --decode) --h-Subject &subj --body &email_body --attach &attachment";
Is it possible that SAS also decoded my password into another password, which led to unsuccessful authentication?