Hello
I am running a code to send an email from SAS program.
I get an error:
ERROR: Email host smtprelay not found.
What is the way to solve it please?
/****Send Report via email***********/
/****Send Report via email***********/
/****Send Report via email***********/
FILENAME mail
EMAIL TO="<Dave.tein@gmail.com>"
CC=("Dave.tein@gmail.com","Dave.tein@gmail.com")
FROM='<Dave.tein@gmail.com>'
SUBJECT="Summary Data"
CONTENT_TYPE="text/html"
encoding="utf-8";
ODS LISTING CLOSE;
ODS HTML BODY=mail;
proc report data=sashelp.cars nowd noheader ;
run;
proc report data = SasHelp.Cars(obs = 5) split = "*";
column Type MPG_Ratio MPG_City MPG_Highway;
define Type / display ;
define MPG_City / display;
define MPG_Highway / display;
define MPG_Ratio / computed 'City/Highway' format = 4.2;
compute MPG_Highway;
MPG_Ratio = MPG_City/MPG_Highway;
endcomp;
run;
ODS HTML CLOSE;
ODS LISTING;
Here is the Log
1 The SAS System 09:54 Sunday, January 1, 2023 1 ;*';*";*/;quit;run; 2 OPTIONS PAGENO=MIN; 3 %LET _CLIENTTASKLABEL='AAA'; 4 %LET _CLIENTPROCESSFLOWNAME='Process Flow'; 5 %LET _CLIENTPROJECTPATH=''; 6 %LET _CLIENTPROJECTPATHHOST=''; 7 %LET _CLIENTPROJECTNAME=''; 8 %LET _SASPROGRAMFILE='K:\RON EINSTEIN\LEARN\AAA.sas'; 9 %LET _SASPROGRAMFILEHOST='VSK2H010A3280'; 10 11 ODS _ALL_ CLOSE; 12 OPTIONS DEV=PNG; 13 GOPTIONS XPIXELS=0 YPIXELS=0; 14 FILENAME EGSR TEMP; 15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR 16 STYLE=HTMLBlue 17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css") 18 NOGTITLE 19 NOGFOOTNOTE 20 GPATH=&sasworklocation 21 ENCODING=UTF8 22 options(rolap="on") 23 ; NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR 24 25 GOPTIONS ACCESSIBLE; 26 27 /****Send Report via email***********/ 28 FILENAME mail 29 EMAIL TO="<Dave.tein@gmail.com>" 30 CC=("Dave.tein@gmail.com","Dave.tein@gmail.com") 31 FROM='<Dave.tein@gmail.com>' 32 SUBJECT="פאנל העמדות -פרטיים" 33 CONTENT_TYPE="text/html" 34 encoding="utf-8"; 35 ODS LISTING CLOSE; 36 ODS HTML BODY=mail; NOTE: Writing HTML Body file: MAIL 37 38 proc report data=sashelp.cars nowd noheader ; 39 run; NOTE: Multiple concurrent threads will be used to summarize data. NOTE: There were 428 observations read from the data set SASHELP.CARS. NOTE: PROCEDURE REPORT used (Total process time): real time 0.39 seconds user cpu time 0.38 seconds system cpu time 0.01 seconds memory 8210.00k OS Memory 41400.00k Timestamp 01/01/2023 01:51:11 PM Step Count 582 Switch Count 1 Page Faults 0 Page Reclaims 1866 Page Swaps 0 Voluntary Context Switches 23 Involuntary Context Switches 1 Block Input Operations 0 2 The SAS System 09:54 Sunday, January 1, 2023 Block Output Operations 0 40 41 proc report data = SasHelp.Cars(obs = 5) split = "*"; 42 column Type MPG_Ratio MPG_City MPG_Highway; 43 define Type / display ; 44 define MPG_City / display; 45 define MPG_Highway / display; 46 define MPG_Ratio / computed 'City/Highway' format = 4.2; 47 compute MPG_Highway; 48 MPG_Ratio = MPG_City/MPG_Highway; 49 endcomp; 50 run; NOTE: Multiple concurrent threads will be used to summarize data. NOTE: There were 5 observations read from the data set SASHELP.CARS. NOTE: PROCEDURE REPORT used (Total process time): real time 0.01 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 8334.50k OS Memory 43968.00k Timestamp 01/01/2023 01:51:11 PM Step Count 583 Switch Count 1 Page Faults 0 Page Reclaims 1826 Page Swaps 0 Voluntary Context Switches 35 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 51 52 ODS HTML CLOSE; ERROR: Email host smtprelay not found. 53 ODS LISTING; 54 55 GOPTIONS NOACCESSIBLE; 56 %LET _CLIENTTASKLABEL=; 57 %LET _CLIENTPROCESSFLOWNAME=; 58 %LET _CLIENTPROJECTPATH=; 59 %LET _CLIENTPROJECTPATHHOST=; 60 %LET _CLIENTPROJECTNAME=; 61 %LET _SASPROGRAMFILE=; 62 %LET _SASPROGRAMFILEHOST=; 63 64 ;*';*";*/;quit;run; 65 ODS _ALL_ CLOSE; 66 67 68 QUIT; RUN; 69
I do not fully understand your description. The code quoted does work if run on its own, but when merged with the code quoted above and run with that it does not? Is it that?
If so ... could you check for differences in the smtp setup in both cases?
proc options group=email; run;
Just to ensure that we are walking down the same road.
I dont understand, may you modify my code and show me and I will check it?
I can only try ... as I said, I have not used that before. What would be the email server you would like/can use? This depends on the OS settings (where the SAS system runs). If you do not know that you needed to have a chat with your admin.
SAS needs an smtp server to relay the message. The error indicates there is none.
You need the following statement at the beginning
options
emailsys=smtp
emailhost= <your.smtpemail.server.com >
emailport=<server port typically 25>;
On server this typically set by the administrator.
The exact solution depends on whether you are having SAS on your PC/Laptop or whether it is running on the server.
If you have SAS locally installed on your machine then one feasible option will be to use either details from your ISP or email provider (google/outlook/yahoo etc). This reference helps for google
https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/
The following are excellent references on the subject.
https://communities.sas.com/t5/SAS-Communities-Library/How-to-send-email-using-SAS/ta-p/746523
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hosto390/p0kgzksjepofk2n15jlvg9yd8a5r.htm
Thank you very much for the kb reference ... I guess that will be of great help! --fja
As I said, you need to have a notion what _smtp_ server to use. This actually depends on your system setup. Otherwise we could try to use an external smtp server (like the google thingy in the first link in @Sajid01 's posting above).
Ask your SAS administrator whether your SAS installation has been setup to send email or not. Normally email settings are configured and tested at installation time so they should know what they are. If your SAS has never been configured to send email then it is really their responsibility to get it working.
EDIT: Since you are getting an error regarding email host smtprelay that suggests there are some default email settings. Again talk to your SAS administrator regarding this error (once back from holiday).
@fja wrote:
Well, here there seems to be a problem. Could be due to a principal misconfiguration or might be due to a side effect of some update ... as the change of the year is a popular day to change things in IT.
Year end/beginning is typically a time where there is a change freeze to not put year end processing at risk.
You can set below options yourself at the start of your program.
"Any" email server will work that's accessible from where SAS executes. The SAS Admin on your site should be able to provide you the email server name and port if there is any. ...and ideally then also configures these values as default for the whole SAS environment so you don't have to define it in your code.
@Patrick wrote:Year end/beginning is typically a time where there is a change freeze to not put year end processing at risk.
Would not be too sure on that. It depends on the system and purpose ... i.e. if there is a dedicated year end processing.
Nevertheless we all seem to agree on the actions to be taken ... let's see what @Ronein comes up with.
Hello @Ronein
If SAS is running on the server, then the SAS Administrator (of somebody performing the SAS administration) is the first person you should speak to. Seniors/peers in your organization would also be helpful. Hopefully your issues will be resolved.
Hello
I talked with admin and he gave me the hostmail smtp.tleumi
However ,now I get another error
ERROR: Email: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
My questions:
What does it mean?
What is this error?
How can I solve it?
options
emailsys=smtp
emailhost=smtp.tleumi
emailport=25;
OPTIONS EMAILSYS = SMTP;
FILENAME mail
EMAIL TO="Dave.Stein@gmail.coml"
FROM='Dave.Stein@gmail.coml'
SUBJECT="XXXXXX"
CONTENT_TYPE="text/html"
encoding="utf-8";
ODS LISTING CLOSE;
ODS HTML BODY=mail;
proc report data=sashelp.cars ;
run;
ODS HTML CLOSE;
ODS LISTING;
Please see the Log
1 The SAS System 09:54 Sunday, January 1, 2023 1 ;*';*";*/;quit;run; 2 OPTIONS PAGENO=MIN; 3 %LET _CLIENTTASKLABEL='AAA'; 4 %LET _CLIENTPROCESSFLOWNAME='Process Flow'; 5 %LET _CLIENTPROJECTPATH=''; 6 %LET _CLIENTPROJECTPATHHOST=''; 7 %LET _CLIENTPROJECTNAME=''; 8 %LET _SASPROGRAMFILE='K:\RON EINSTEIN\LEARN\AAA.sas'; 9 %LET _SASPROGRAMFILEHOST='VSK2H010A3280'; 10 11 ODS _ALL_ CLOSE; 12 OPTIONS DEV=PNG; 13 GOPTIONS XPIXELS=0 YPIXELS=0; 14 FILENAME EGSR TEMP; 15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR 16 STYLE=HTMLBlue 17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css") 18 NOGTITLE 19 NOGFOOTNOTE 20 GPATH=&sasworklocation 21 ENCODING=UTF8 22 options(rolap="on") 23 ; NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR 24 25 GOPTIONS ACCESSIBLE; 26 27 options 28 emailsys=smtp 29 emailhost=smtp.tleumi 30 emailport=25; 31 OPTIONS EMAILSYS = SMTP; 32 FILENAME mail 33 EMAIL TO="Dave.Stein@gmail.coml" 34 FROM='Dave.Stein@gmail.coml' 35 SUBJECT="XXXXXX" 36 CONTENT_TYPE="text/html" 37 encoding="utf-8"; 38 ODS LISTING CLOSE; 39 ODS HTML BODY=mail; NOTE: Writing HTML Body file: MAIL 40 proc report data=sashelp.cars ; 41 run; NOTE: Multiple concurrent threads will be used to summarize data. NOTE: There were 428 observations read from the data set SASHELP.CARS. NOTE: PROCEDURE REPORT used (Total process time): real time 0.43 seconds user cpu time 0.40 seconds system cpu time 0.01 seconds memory 8228.96k OS Memory 41400.00k Timestamp 01/02/2023 09:50:01 AM Step Count 605 Switch Count 1 Page Faults 0 Page Reclaims 1896 Page Swaps 0 Voluntary Context Switches 31 2 The SAS System 09:54 Sunday, January 1, 2023 Involuntary Context Switches 1 Block Input Operations 0 Block Output Operations 0 42 ODS HTML CLOSE; ERROR: Email: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM 43 ODS LISTING; 44 45 GOPTIONS NOACCESSIBLE; 46 %LET _CLIENTTASKLABEL=; 47 %LET _CLIENTPROCESSFLOWNAME=; 48 %LET _CLIENTPROJECTPATH=; 49 %LET _CLIENTPROJECTPATHHOST=; 50 %LET _CLIENTPROJECTNAME=; 51 %LET _SASPROGRAMFILE=; 52 %LET _SASPROGRAMFILEHOST=; 53 54 ;*';*";*/;quit;run; 55 ODS _ALL_ CLOSE; 56 57 58 QUIT; RUN; 59
You most probably need to also supply a username and password to authenticate on your SMTP server.
Scan the documentation for the EMAIL... options to see how to supply your credentials to the SAS system.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.