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

 

 

options emailsys = smtp 
emailauthprotocol= login
EMAILACKWAIT=30
emailid = 'runnerupwang@outlook.com'
emailpw = 'XXXXXX'
emailhost = 'smtp.live.com' 
emailport = 25 ;
filename f_email email 
to =   '1055103120@qq.com'
from = 'runnerupwang@outlook.com'
subject = 'Automatic Email Sending Test'
;
data _null_;
file f_email;
put 'This is a test email with an RTF attachment via SAS programming.';
run;

I'm trying to send the email in the SAS9.4 with outlook mail, but failed, and I got an error message below, it seems that I should specify SSL, but I don't know how. Thanks for your info

 

ERROR: Login Failed
ERROR: Email: 530 5.7.0 Must issue a STARTTLS command first

 

PS: This code works if I changed the sender to 163 mail, and emaihost to smtp.163.com

1 ACCEPTED SOLUTION

Accepted Solutions
DMO467
SAS Employee
I suggest you also take a look at the following

Usage Note 53215: How to set up your SAS® installation to use Secure SMTP via Gmail at:

http://support.sas.com/kb/53/215.html

More information on the options= emailhost option for SAS V9.4 can be found here:

http://support.sas.com/documentation/cdl/en/lesysoptsref/68023/HTML/default/viewer.htm#p1v9dr6zep9p9...

Here is some sample code:

options emailsys = smtp
emailid = 'runnerupwang@outlook.com'
emailpw = 'XXXXXX'
emailhost = 'smtp.live.com'
emailport = 25 ;

options emailhost=
(
"smtp.live.com"
STARTTLS auth=LOGIN
/* your Outlook address */
id=" runnerupwang@outlook.com
/* optional: encode PW with PROC PWENCODE */
pw="XXXXX" port=587
)
;
filename f_email email
to = '1055103120@qq.com'
from = 'runnerupwang@outlook.com'
subject = 'Automatic Email Sending Test';

data _null_;
file f_email;
put 'This is a test email with an RTF attachment via SAS programming.';
run;


View solution in original post

4 REPLIES 4
DMO467
SAS Employee
I suggest you also take a look at the following

Usage Note 53215: How to set up your SAS® installation to use Secure SMTP via Gmail at:

http://support.sas.com/kb/53/215.html

More information on the options= emailhost option for SAS V9.4 can be found here:

http://support.sas.com/documentation/cdl/en/lesysoptsref/68023/HTML/default/viewer.htm#p1v9dr6zep9p9...

Here is some sample code:

options emailsys = smtp
emailid = 'runnerupwang@outlook.com'
emailpw = 'XXXXXX'
emailhost = 'smtp.live.com'
emailport = 25 ;

options emailhost=
(
"smtp.live.com"
STARTTLS auth=LOGIN
/* your Outlook address */
id=" runnerupwang@outlook.com
/* optional: encode PW with PROC PWENCODE */
pw="XXXXX" port=587
)
;
filename f_email email
to = '1055103120@qq.com'
from = 'runnerupwang@outlook.com'
subject = 'Automatic Email Sending Test';

data _null_;
file f_email;
put 'This is a test email with an RTF attachment via SAS programming.';
run;


Wang_Yajun
Obsidian | Level 7

Thanks for your support. The final solution for sending the email with Outlook Account is similar to your sample code. I have setup the emailhost option in the second part option, I wonder why I have to setup the first part system options. 

 

 

/*First part Option Setup*/
options emailsys = smtp emailauthprotocol= login EMAILACKWAIT=30 emailid = '******@outlook.com' emailpw = 'XXXXXX' emailhost = 'smtp-mail.outlook.com' emailport = 25 ;
/*Second part Option Setup*/ options emailhost= ( 'smtp-mail.outlook.com' port=587 STARTTLS auth=login id='******@outlook.com' /* optional: encode PW with PROC PWENCODE */ pw='XXXXXX' ) ; filename f_email email to = ('OutMail_Address1' 'OutMail_Address2') subject = 'Automatic Email Sending Test' attach = 'C:\Users\Think\Desktop\test.rtf' ; data _null_; file f_email; put 'This is a test email with an RTF attachment via SAS programming.'; run; filename f_email clear;

 

DMO467
SAS Employee
The difference between these two is that SMTP over SSL first establishes a secure SSL/TLS connection and conducts SMTP over that connection, and SMTP with STARTTLS starts with unencrypted SMTP and then switches to SSL/TLS. This is why the email STMP system options in the SAS code are specified first, and the email host options STARTTLS are specified second.

Check this post out if you require further information:

http://stackoverflow.com/questions/17281669/using-smtp-gmail-and-starttls

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 14855 views
  • 2 likes
  • 3 in conversation