Jump to content


Photo
- - - - -

[download] Module: SSMTP - Send email using SSL.


  • Please log in to reply
5 replies to this topic

#1 123

123

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2146 posts
  • Location:Montreal, QC
  • Experience:average
  • Software:Premise
  • Hardware:Elk M1

Posted 15 May 2010 - 08:31 PM

File Name: Module: SSMTP - Send email using SSL.
File Submitter: 123
File Submitted: 15 May 2010
File Category: Premise
Author: 123
Contact: PM me
Version: 1.3

SSMTP is a driver that provides a convenient means to send email via Secure SMTP. It offers the following conveniences:

Secure SMTP
SSMTP relies on Collaborative Data Objects (CDO) in order to send email using Secure Socketsw Layer (SSL). In addition, SSMTP supports authentication which, together with SSL, ia required if you wish to send email via Google's Gmail service.

Centralized device
The SSMTP is a custom device driver so it resides in Devices > CustomDevices > SSMTP. Let's say you've preconfigured it to send email, via Gmail (smtp.gmail.com), to your phone. If you ever need to change the destination or carrier, you don't need to modify every script that sends email, you simply change it in the SSMTP device.

Default values
SSMTP can be preconfigured with default values. For example, it can be configured to send email via your Gmail account to you and your spouse. As a result, email scripts are simplified because you only need to specify a Subject and Body. Other properties such as From, To, MailServer, Account, Password, etc are all predefined by you. Here's a sample email script that relies on a preconfigured SSMTP device:
with Device.CustomDevices.SSMTP
	.Subject = "Warning: Garage Door left open."
	.MailHTMLBody = "Garage door left open:" & now
	.MailSend = true
end with

Auto-reset
Your script can override a default value and specify a unique one. After the email is sent, the default values are automatically restored. For example, the following script overrides MailTo's default value. After the message is processed, MailTo will be restored to its default value.
with Device.CustomDevices.SSMTP
	.Subject = "Warning: Garage Door left open."
	.MailTo = "[email protected], [email protected]"
	.MailHTMLBody = "Garage door left open:" & now
	.MailSend = true
end with

MailLog
SSMTP keeps a record of the last five email messages. The message's Status property will indicate the transmission time or, if a problem was encountered, the cause of the failure.

Installation
Using Builder, import the attached XDO file.

Configuration
  • In the Shortcut bar, click Modules.
  • In the Explorer window, navigate to Modules > SSMTP > Classes > SSMTP
  • Click the MailFrom property.
  • In the Properties window, locate and set MailFrom's default value.
  • Repeat this procedure for MailTo.
  • In the Explorer window, navigate to Modules > SSMTP > Classes > SSMTPConfiguration
  • Click the SMTPServer property.
  • In the Properties window, locate and set SMTPServer's default value.
  • Repeat this procedure for all other SMTP properties.
  • In the Shortcut bar, click Devices.
  • In the Explorer window, right-click Devices > CustomDevices and select New > SSMTP. An SSMTP device will appear in the list containing properties with the default values you've chosen.

Usage
Here's a script fragment that emails CallerID information.
with Devices.CustomDevices.SSMTP
				.MailSubject = "Telephone call: " & this.CallerIDName & ", " & this.CallerIDNumber
				.MailHTMLBody = "<b>Name:&nbsp;</b>" & this.CallerIDName & "<br>" & _
								"<b>Number:&nbsp;</b>" & this.CallerIDNumber & "<br>"  & _
								"<b>Time:&nbsp;</b>" & this.CallerIDDateTime & "<br>"  & _
								"<b>CallsAway:&nbsp;</b>" & this.CallsAway & "<br>" 
				.MailSend = true
			end with

Notes
  • The fully-qualified email format is (for multiple recipients): "John" <[email protected]>, "Mary" <[email protected]>
  • The simplest email format is (for multiple recipients): [email protected], [email protected]
  • Email messages typically contain content in two forms, in HTML and in text-only. It is preferable to use the MailHTMLBody property instead of MailTextBody. The driver will automatically strip the HTML tags from MailHTMLBody and use that to populate the MailTextBody property. If you do use MailTextBody, the driver will simply copy its contents to MailHTMLBody (without HTML tags).

Click here to download this file

#2 Charlie Kindel

Charlie Kindel

    Cocooner

  • Registered
  • PipPip
  • 70 posts

Posted 26 September 2012 - 06:46 PM

First example has two typos:

"Device." should be "Devices."

".Subject =" should be ".MailSubject ="

#3 Charlie Kindel

Charlie Kindel

    Cocooner

  • Registered
  • PipPip
  • 70 posts

Posted 26 September 2012 - 07:07 PM

Microsoft Office365's SMTP servers use SSL, but on a different port (587). You don't support setting the SSL port.

I looked at the code and changed:


if this.SMTPUseSSL then

.Item (sPath & "smtpserverport") = 465


to


if this.SMTPUseSSL then

.Item (sPath & "smtpserverport") = 587


I still get 'The transport failed to connect to the server.'

I've verified that my setup is working correctly by using a gmail address (and port 465).

Any suggestions?

#4 Charlie Kindel

Charlie Kindel

    Cocooner

  • Registered
  • PipPip
  • 70 posts

Posted 26 September 2012 - 07:40 PM

Ok, regarding this problem:

Turns out Office365 requires you to use port 25 when doing TLS over SSL.

I changed this module as follows:

I added a new property to SSMTP.Classes.SSMPTConfiguration:
SMTPSSLPort - Integer, default value 465

I changed SendMail:


if this.SMTPUseSSL then
.Item (sPath & "smtpserverport") = this.SMTPSSLPort
.Item (sPath & "smtpusessl") = True
else
.Item (sPath & "smtpserverport") = 25
.Item (sPath & "smtpusessl") = False
end if

Then for MY configuration I set SMTPSSLPort to 25 and it works.

Cheers!

#5 Charlie Kindel

Charlie Kindel

    Cocooner

  • Registered
  • PipPip
  • 70 posts

Posted 17 August 2014 - 05:44 PM

It appears this TLS hack no longer works. CDO does not support TLS. I was able to get SSTMP working again by installing https://smtpproxy.codeplex.com/ and using it as a proxy. I configured SSMTP to NOT use SSL and the server of smtp.office365.com and now it is all working.



#6 chucklyons

chucklyons

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 778 posts
  • Software:Premise

Posted 27 August 2019 - 03:46 PM

I have started using Gmail as my SMTP proxy. Even after adding Charlie's changes (above), I was getting either locked out or security errors from Gmail.
It turns out Premise (c. 2000) is considered "Unsafe". However, after some searching, I now have 123's SSMTP working. Again.
 
To use Gmail as an SMTP proxy:
   1) Either use your Gmail account ID or create one if you want to identify where the email is coming from (I added a .Premise, so I know    which house its coming from)
   2) Login to your account (or the one you just created), and select "Account", then "Security"
   3) Scroll down to "Signing In To Google"
   4) Enable Two Step Verification (You'll now have to go thru some verification steps; just follow the instructions)
   5) Once Two Step Verification is enabled, you should see an additional option under "Signing In To Google" called "App Passwords"

   6) Select "App Passwords"; reenter your password

   7) Select "Select App" and go to "Other (Custom Name)"

   8) Create your App Name, then select "Generate"

   9) You will then get a popup box that will display your App Password (4 sets of 4 characters). Capture the password.

 

On 123's SSMTP Module (sys://Schema/Modules/SSMTP/Classes/SMTPConfiguration/):

         SMTPServer:       smtp.gmail.com

          SMTPTimeout:    30

          SMTPAccount:    Your Gmail username (or the one you created)

          SMTPPassword: The 4 character set password (your App Password)

          SMTPUseSSL:    True

          SMTPSSLPort:    465

 

I've ran this for a few days of messages without a hitch...


Edited by chucklyons, 27 August 2019 - 04:08 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users