SMTPSecureSocket

From Xojo Documentation
Jump to: navigation, search

Class (inherits from SSLSocket)

Used to send secure email via the SMTP protocol using SSL or TLS encryption.

Events
ConnectionEstablished MailSent SendProgress
Error MessageSent ServerError


Properties
Address Handle ReadOnlyProperty.png Port
BytesAvailable ReadOnlyProperty.png IsConnected ReadOnlyProperty.png RemoteAddress ReadOnlyProperty.png
BytesLeftToSend ReadOnlyProperty.png LastErrorCode ReadOnlyProperty.png SMTPConnectionMode
CertificateFile LocalAddress ReadOnlyProperty.png SSLConnected ReadOnlyProperty.png
CertificatePassword Messages SSLConnecting ReadOnlyProperty.png
CertificateRejectionFile NetworkInterface Secure
ConnectionType Password UserName


Methods
Close DisconnectFromServer Purge
Connect Listen ReadAll
DeleteAllMessages Lookahead SendMail
Disconnect Poll

Constants

For use with SMTPConnectionMode property:

  • ModeSTARTTLS = 0
  • ModeSSLTLS = 1

Notes

The SMTPSecureSocket class is the same as the SMTPSocket class except that it is derived from SSLSocket instead of TCPSocket. As a result, you can use the Secure property of the SSLSocket class to provide secure communications.

If you use a constructor in a subclass of a SMTPSecureSocket, you must call the Super class's constructor in your subclass's constructor. The subclass will not work unless this is done.

Gmail

In order to connect to Gmail you'll need to enable the "allow less secure apps" option as described in this Google support document:

https://support.google.com/accounts/answer/6010255

With that enabled, these settings work for most users:

MailSocket.Port = 465
MailSocket.ConnectionType = SMTPSecureSocket.TLSv1
MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
MailSocket.Secure = True

Xojo Cloud

To access an SMTP server from web apps running on Xojo Cloud, you will first have to use the FirewallPort class to open the port used to connect to the SMTP Server:

Dim fwp As New XojoCloud.FirewallPort(587, _
XojoCloud.FirewallPort.Direction.Outgoing)
fwp.Open // This call is synchronous
If fwp.isOpen Then
// Do what you need to do
End If

See Also

EmailMessage, HTTPSecureSocket, HTTPSocket, POP3SecureSocket, TCPSocket, POP3Socket, SMTPSocket, SocketCore classes.]

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About