|
Class: SMTPClient
Object
|
+--NVTClient
|
+--SMTPClient
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-SMTP
- Version:
- rev:
1.34
date: 2022/03/11 19:34:53
- user: cg
- file: SMTPClient.st directory: goodies/communication
- module: stx stc-classLibrary: communication
a very simple SMTP mail client.
Right now, there are two entries:
sendMessageString:
which expects a string argument, containing all of
the mail info (from lines, subject etc.)
sendMessage:
which expects a letter object, which itself is able
to convert itself to a string. At the time of writing,
such a letter object does not exist,
copyrightCOPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
class initialization
-
initialize
-
self initialize.
signal constants
-
smtpErrorSignal
-
accessing
-
addHeaderLine: aString
-
add a string (in the form 'keyword: line') to be sent in the mail header
-
addHeaderLines: aCollection
-
add a string (in the form 'keyword: line') to be sent in the mail header
-
clientHostName
-
-
clientHostName: something
-
defaults
-
defaultPassword
-
-
defaultPort
-
SMTPS
-
defaultUser
-
initialization
-
initialize
-
operations
-
sendMessage: rfc822Message
-
send an rfc822Message (Net::MailMessage)
-
sendMessage: rfc822Message to: receiver
-
send an rfc822Message
-
sendMessage: rfc822Message toAll: receivers
-
send an rfc822Message
-
sendMessageString: rfc822MessageString to: receiver
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString toAll: receivers
-
send an rfc822MessageString
Usage example(s):
|snmp|
snmp := SMTPClient new.
snmp connectTo:'exept'.
snmp userName:'cg@exept.de'.
snmp sendMessageString:'this is a test message\.\last line' withCRs to:'cg@exept.de'.
snmp close
|
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver cc: ccReceiver bcc: bccReceiver
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver fromLabel: fromLabel
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers fromLabel: fromLabel
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers toAllCc: ccReceivers toAllBcc: bccReceivers
-
-
sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers toAllCc: ccReceivers toAllBcc: bccReceivers fromLabel: fromLabel
-
send an rfc822MessageString
Usage example(s):
|smtp|
smtp := SMTPClient new.
smtp connectTo:'bar'.
smtp userName:'foo@bar.baz'.
smtp sendMessageString:('this is a test message cc/bcc \.\last line' withCRs)
withSubject:'test cc/bcc [4]'
contentType:nil
toAll:#('foo@bar.baz')
toAllCc:#('fooCC@bar.baz')
toAllBcc:#('fooBcc@bar.baz').
smtp close
|
-
sendMessageString: rfc822MessageString withSubject: aSubjectString to: receiver
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString to: receiver cc: ccReceiver bcc: bccReceiver
-
send an rfc822MessageString
-
sendMessageString: rfc822MessageString withSubject: aSubjectString toAll: receivers
-
|snmp|
snmp := SMTPClient new.
snmp connectTo:'exept'.
snmp userName:'penk@exept.de'.
snmp sendMessageString:('this is a test message\.\last line' withCRs) withSubject:'Message from SmalltalkX' to:'penk@exept.de'.
snmp close
-
verifyUser: userName
-
|snmp|
snmp := SMTPClient new.
snmp connectTo:'exept'.
Transcript showCR:(snmp verifyUser:'fooUser').
snmp close
private - commands & responses
-
handleReplyCode: replyCode
-
Raise an error if the last response from the SMTP server has an error.
-
sendGoodByeCommand
-
(comment from inherited method)
invoked before the socket connection is shutDown.
A subclass implementation may want to redefine this for a graceful goodBy
(typically sending a quit-command)
private - connection setup
-
getInitialConnectResponse
-
(comment from inherited method)
invoked right after the socket connection has been setup;
subclass implementation should read all initial hello-bla
-
performLoginSequence
-
invoked after the socket connection has been setup
-
sendEhlo
-
send the extended EHLO command and get the supported capabilities
Use host:port - port is optional.
SMTPClient new
useSTARTTLS;
connectTo:'exeptn.bh.exept.de:587' user:'stefan';
sendMessageString:'This is a test message\.\last line' withCRs
withSubject:'STARTTLS testmail'
to:'stefan@exept.de';
close.
|
SMTPClient new
userName:'sr';
connectTo:(IPSocketAddress localHost);
sendMessageString:'this is a test message\.\last line' withCRs
to:'stefan.reise@gmx.de';
close.
|
SMTPClient new
useSSL;
userName:'stefan';
connectTo:(IPSocketAddress hostName:'exeptn');
sendMessageString:'This is a test message \.\last line' withCRs
withSubject:'SSL testmail'
to:'stefan@exept.de';
close.
|
|m|
m := Net::MailMessage new.
m
from:'stefan.reise@exept.de';
to:'stefan.reise@gmx.de';
subject:'Test von stx';
contents:'Dies ist ein mailtext';
yourself.
SMTPClient new
userName:'stefan.reise';
password:'rappel72';
connectTo:(IPSocketAddress hostName:'mail.exept.de');
sendMessage:m;
close.
|
|