SMTPSendMail>recipients,server,from_address,from_name,subject,body,attachments
Not supported in Macro Scheduler Lite.
Sends email via an SMTP server to the recipients entered.
recipients : Include one or more email addresses, separated by semicolons (;).
server : The name or IP address of your SMTP server.
from_address : Your email address, or the email address you want the message to come from.
from_name : Your real name, or a string to appear in the from name field.
subject : The subject line.
body : The body text of the message (default is text, to send HTML set SMTP_HTMLBODY to 1).
attachments : if sending files include each file separated by semicolons (;). If no attachments end the line with a comma.
By default when this command is in use a small status window will appear at the top left of the screen. You can stop this window being displayed by setting SENDMAIL_STATUS to 0.
To send HTML set SMTP_HTMLBODY to 1.
To include CC or BCC email addresses set the SMTP_CCLIST and SMTP_BCCLIST variables. Separate multiple email address with semicolons.
If you are using an SMTP server that requires authentication, you can enable authentication by setting SMTP_AUTH to 1, and then setting SMTP_USERID and SMTP_PASSWORD to the username and password that you need to connect to the SMTP server. e.g:
Let>SMTP_AUTH=1
Let>SMTP_USERID=myuser
Let>SMTP_PASSWORD=frogslegs
Since 15.5.07 SMTPSendMail now supports oAuth2 authentication via the SMTP_OAUTH2 and SMTP_OAUTH2_TOKEN variables. See example and explanation below.
To enable return receipt of the email, set SMTP_RECEIPT to 1.
By default the port used by SMTPSendMail is 25. If you need to change the port number set the value of SMTP_PORT.
The result of the sendmail operation is placed into the variable SMTP_RESULT. The format of this response depends on the SMTP server being communicated with. If successful the value will contain the result code 250. Otherwise it will contain the appropriate error message.
SMTP_TIMEOUT can be used to set a connection timeout in seconds. This timeout relates to the initial connection to the SMTP server and, since version 15.5.07, subsequent operations.
To use SSL set SMTP_SSL to 1. To use SSL you will first need to install the OpenSSL libraries. See:
http://www.openssl.org/related/binaries.html and http://www.mjtnet.com/blog/2012/10/03/sendingretrieving-emails-via-gmail/
If TLS is needed you can set how it should be used by setting SMTP_USETLS as follows:
|
0 |
No TLS/SSL |
Default - no encryption |
|
1 |
Use Implicit TLS |
You wish to use implicit TLS. In implicit TLS FTP, you connect to port 990, start TLS negotiation, and the entire session is encrypted. IETF has depreciated implicit TLS FTP so this setting should only be used with FTP servers that do not yet support explicit TLS. |
|
2 |
Use Require TLS |
You wish your session to use explicit TLS. In explicit TLS FTP, you connect to port 21 like the unencrypted version of FTP and encryption lasts until you disconnect. No attempt is made to continue the FTP session if TLS negotiation fails. |
|
3 |
Use Explicit TLS |
You wish your session to use explicit TLS if the FTP server supports it. |
To set TLS version set TLS_VER to one of the following values:
1 TLS v1.0
11 TLS v1.1
12 TLS v1.2
Abbreviation : SMT
See also: RetrievePOP3
Example
Let>SENDMAIL_STATUS=1
Let>subject=Test Message
Let>myname=Mr Smith
Let>[email protected];[email protected]
Input>body,Enter your message:
SMTPSendMail>recipients,post.mail.com,me,myname,subject,body,
Message>Result of SendMail: %SMTP_RESULT%
Example using oAuth2
Let>SMTP_OAUTH2=1
Let>SMTP_OAUTH2_TOKEN=ya29.a0AfH6SMBx...
Let>[email protected]
Let>SMTP_SSL=1
Let>SMTP_PORT=465
SMTPSendMail>[email protected],smtp.gmail.com,[email protected],Your Name,Test subject,Test body,
Note that SMTPSendMail is not responsible for exchanging/retrieving the token - The script (or another tool) must get the access token from the provider (e.g. Azure AD, Google) and set SMTP_OAUTH2_TOKEN before SMTPSendMail.
There should be a process with your email provider to create an 'app' and get app credentials - usually a client ID and a client secret. You would then use these in an API endpoint to get a refresh token. Refresh tokens are usually long lived and you would need to exchange the refresh token for an access token which is used in the SMTP_OAUTH2_TOKEN variable. So you'd need to store refresh tokens securely and use HTTPRequest or similar to do the token exchanges to get the access token each time you need to email.