1smtp(n) smtp client smtp(n)
2
3
4
5______________________________________________________________________________
6
8 smtp - Client-side tcl implementation of the smtp protocol
9
11 package require Tcl
12
13 package require mime ?1.5.4?
14
15 package require smtp ?1.4.5?
16
17 ::smtp::sendmessage token option...
18
19_________________________________________________________________
20
22 The smtp library package provides the client side of the Simple Mail
23 Transfer Protocol (SMTP) (1) (2).
24
25 ::smtp::sendmessage token option...
26 This command sends the MIME part (see package mime) represented
27 by token to an SMTP server. options is a list of options and
28 their associated values. The recognized options are:
29
30 -servers
31 A list of SMTP servers. The default is localhost.
32
33 -ports A list of SMTP ports. The default is 25.
34
35 -client
36 The name to use as our hostname when connecting to the
37 server. By default this is either localhost if one of the
38 servers is localhost, or is set to the string returned by
39 info hostname.
40
41 -queue Indicates that the SMTP server should be asked to queue
42 the message for later processing. A boolean value.
43
44 -atleastone
45 Indicates that the SMTP server must find at least one
46 recipient acceptable for the message to be sent. A bool‐
47 ean value.
48
49 -originator
50 A string containing an 822-style address specification.
51 If present the header isn't examined for an originator
52 address.
53
54 -recipients
55 A string containing one or more 822-style address speci‐
56 fications. If present the header isn't examined for
57 recipient addresses). If the string contains more than
58 one address they will be separated by commas.
59
60 -header
61 A list of keywords and their values (may occur zero or
62 more times).
63
64 -usetls
65 This package supports the RFC 3207 TLS extension (3) by
66 default provided the tls package is available. You can
67 turn this off with this boolean option.
68
69 -tlspolicy
70 This option lets you specify a command to be called if an
71 error occurs during TLS setup. The command is called with
72 the SMTP code and diagnostic message appended. The com‐
73 mand should return 'secure' or 'insecure' where insecure
74 will cause the package to continue on the unencrypted
75 channel. Returning 'secure' will cause the socket to be
76 closed and the next server in the -servers list to be
77 tried.
78
79 -username
80
81 -password
82 If your SMTP server requires authentication (RFC 2554
83 (4)) before accepting mail you can use -username and
84 -password to provide your authentication details to the
85 server. Currently this package supports DIGEST-MD5, CRAM-
86 MD5, LOGIN and PLAIN authentication methods. The most
87 secure method will be tried first and each method tried
88 in turn until we are either authorized or we run out of
89 methods. Note that if the server permits a TLS connec‐
90 tion, then the authorization will occur after we begin
91 using the secure channel.
92
93 If the -originator option is not present, the originator address is
94 taken from From (or Resent-From); similarly, if the -recipients option
95 is not present, recipient addresses are taken from To, cc, and Bcc (or
96 Resent-To, and so on). Note that the header key/values supplied by the
97 -header option (not those present in the MIME part) are consulted.
98 Regardless, header key/values are added to the outgoing message as nec‐
99 essary to ensure that a valid 822-style message is sent.
100
101 The command returns a list indicating which recipients were unaccept‐
102 able to the SMTP server. Each element of the list is another list, con‐
103 taining the address, an SMTP error code, and a textual diagnostic.
104 Depending on the -atleastone option and the intended recipients, a non-
105 empty list may still indicate that the message was accepted by the
106 server.
107
109 proc send_simple_message {recipient email_server subject body} {
110 package require smtp
111 package require mime
112
113 set token [mime::initialize -canonical text/plain \\
114 -string $body]
115 mime::setheader $token Subject $subject
116 smtp::sendmessage $token \\
117 -recipients $recipient -servers $email_server
118 mime::finalize $token
119 }
120
121 send_simple_message someone@somewhere.com localhost \\
122 "This is the subject." "This is the message."
123
124
126 [1] Jonathan B. Postel, "SIMPLE MAIL TRANSFER PROTOCOL", RFC 821,
127 August 1982. (http://www.rfc-editor.org/rfc/rfc821.txt)
128
129 [2] J. Klensin, "Simple Mail Transfer Protocol", RFC 2821, April
130 2001. (http://www.rfc-editor.org/rfc/rfc2821.txt)
131
132 [3] P. Hoffman, "SMTP Service Extension for Secure SMTP over Trans‐
133 port Layer Security", RFC 3207, February 2002. (http://www.rfc-
134 editor.org/rfc/rfc3207.txt)
135
136 [4] J. Myers, "SMTP Service Extension for Authentication", RFC 2554,
137 March 1999. (http://www.rfc-editor.org/rfc/rfc2554.txt)
138
140 This document, and the package it describes, will undoubtedly contain
141 bugs and other problems. Please report such in the category smtp of
142 the Tcllib SF Trackers [http://source‐
143 forge.net/tracker/?group_id=12883]. Please also report any ideas for
144 enhancements you may have for either package and/or documentation.
145
147 ftp, http, mime, pop3
148
150 email, internet, mail, mime, net, rfc 2554, rfc 2821, rfc 3207, rfc
151 821, rfc 822, smtp, tls
152
154 Copyright (c) 1999-2000 Marshall T. Rose and others
155
156
157
158
159mime 1.4.5 smtp(n)