The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mail::Transport::SMTP - transmit messages without external program

CLASS INHERITANCE

Mail::Transport::SMTP is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter

SYNOPSIS

 my $sender = Mail::Transport::SMTP->new(...);
 $sender->send($message);

 $message->send(via => 'smtp');

DESCRIPTION

This module implements transport of Mail::Message objects by negotiating to the destination host directly by using the SMTP protocol, without help of sendmail, mail, or other programs on the local host.

METHODS

Initiation

new OPTIONS
 OPTION               DEFAULT
 debug                <false>
 helo_domain          <from Net::Config>
 hostname             <from Net::Config>
 interval             30
 log                  'WARNINGS'
 password             undef
 port                 undef
 proxy                <from Net::Config>
 retry                <false>
 timeout              120
 trace                'WARNINGS'
 username             undef
 via                  'smtp'
debug => BOOLEAN

Simulate transmission: the SMTP protocol output will be sent to your screen.

helo_domain => HOST

The fully qualified name of the sender's host (your system) which is used for the greeting message to the receiver. If not specified, Net::Config or else Net::Domain are questioned to find it. When even these do not supply a valid name, the name of the domain in the From line of the message is assumed.

hostname => HOSTNAME|ARRAY-OF-HOSTNAMES

See Mail::Transport::new(hostname)

interval => SECONDS

See Mail::Transport::new(interval)

log => LEVEL

See Mail::Reporter::new(log)

password => STRING

See Mail::Transport::new(password)

port => INTEGER

See Mail::Transport::new(port)

proxy => PATH

See Mail::Transport::new(proxy)

retry => NUMBER|undef

See Mail::Transport::new(retry)

timeout => SECONDS

The number of seconds to wait for a valid response from the server before failing.

trace => LEVEL

See Mail::Reporter::new(trace)

username => STRING

See Mail::Transport::new(username)

via => CLASS|NAME

See Mail::Transport::new(via)

Server Connection

findBinary NAME [, DIRECTORIES]

See Mail::Transport::findBinary()

remoteHost

See Mail::Transport::remoteHost()

retry

See Mail::Transport::retry()

Sending Mail

contactAnyServer

Creates the connection to the SMTP server. When more than one hostname was specified, the first which accepts a connection is taken. An IO::Socket::INET object is returned.

putContent MESSAGE, FILEHANDLE, OPTIONS

See Mail::Transport::Send::putContent()

send MESSAGE, OPTIONS

See Mail::Transport::Send::send()

tryConnectTo HOST, OPTIONS

Try to establish a connection to deliver SMTP to the specified HOST. The OPTIONS are passed to the new method of Net::SMTP.

trySend MESSAGE, OPTIONS

Try to send the MESSAGE once. This may fail, in which case this method will return false. In list context, the reason for failure can be caught: in list context trySend will return a list of five values:

 (success, error code, error text, error location, quit success)

Success and quit success are booleans. The error code and -text are protocol specific codes and texts. The location tells where the problem occurred.

 OPTION               DEFAULT
 from                 []
 to                   []
from => ADDRESS

Your own identification. This may be fake. If not specified, it is taken from the From field in the header.

to => ADDRESS|[ADDRESSES]

Alternative destinations. If not specified, the To, Cc and Bcc fields of the header are used. An address is a string or a Mail::Address object.

Logging and Tracing

defaultTrace [LEVEL, [LEVEL]

See Mail::Reporter::defaultTrace()

errors

See Mail::Reporter::errors()

log [LEVEL [,STRINGS]]

See Mail::Reporter::log()

report [LEVEL]

See Mail::Reporter::report()

reportAll [LEVEL]

See Mail::Reporter::reportAll()

trace [LEVEL]

See Mail::Reporter::trace()

warnings

See Mail::Reporter::warnings()

Other Methods

AUTOLOAD

See Mail::Reporter::AUTOLOAD()

DESTROY

See Mail::Reporter::DESTROY()

inGlobalDestruction

See Mail::Reporter::inGlobalDestruction()

logPriority LEVEL

See Mail::Reporter::logPriority()

logSettings

See Mail::Reporter::logSettings()

notImplemented

See Mail::Reporter::notImplemented()

SEE ALSO

A good start to read is Mail::Box-Overview. More documentation and a mailinglist are available from the project's website at http://perl.overmeer.net/mailbox/.

AUTHOR

Mark Overmeer (mark@overmeer.net) with the help of many.

VERSION

This code is beta, version 2.025.

Copyright (c) 2001-2002 Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.