smtp - Client-side tcl implementation of the smtp protocol
The smtp library package provides the client side of the smtp protocol.
This command sends the MIME part (see package mime) represented by token to an SMTP server. options is a list of options and their associated values. The recognized options are:
A list of SMTP servers. The default is localhost.
A list of SMTP ports. The default is 25.
Indicates that the SMTP server should be asked to queue the message for later processing. A boolean value.
Indicates that the SMTP server must find at least one recipient acceptable for the message to be sent. A boolean value.
A string containing an 822-style address specification. If present the header isn't examined for an originator address.
A string containing one or more 822-style address specifications. If present the header isn't examined for recipient addresses). If the string contains more than one address they will be separated by commas.
A list of keywords and their values (may occur zero or more times).
This package supports the RFC 3207 TLS extension by default provided the tls package is available. You can turn this off with this boolean option.
This option lets you specify a command to be called if an error occurs during TLS setup. The command is called with the SMTP code and diagnostic message appended. The command should return 'secure' or 'insecure' where insecure will cause the package to continue on the unencrypted channel. Returning 'secure' will cause the socket to be closed and the next server in the -servers list to be tried.
If the -originator option is not present, the originator address is taken from From (or Resent-From); similarly, if the -recipients option is not present, recipient addresses are taken from To, cc, and Bcc (or Resent-To, and so on). Note that the header key/values supplied by the -header option (not those present in the MIME part) are consulted. Regardless, header key/values are added to the outgoing message as necessary to ensure that a valid 822-style message is sent.
The command returns a list indicating which recipients were unacceptable to the SMTP server. Each element of the list is another list, containing the address, an SMTP error code, and a textual diagnostic. Depending on the -atleastone option and the intended recipients, a non-empty list may still indicate that the message was accepted by the server.
proc send_simple_message {recipient email_server subject body} { package require smtp package require mime set token [mime::initialize -canonical text/plain \\ -string $body] mime::setheader $token Subject $subject smtp::sendmessage $token \\ -recipients $recipient -servers $email_server mime::finalize $token } send_simple_message [email protected] localhost \\ "This is the subject." "This is the message."
ftp, http, mime, pop3
email, internet, mail, mime, net, rfc 3207, rfc 821, rfc 822, smtp, tls
Copyright © 1999-2000 Marshall T. Rose