View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Casey West > Email-Send-2.05 > Email::Send::SMTP



Annotate this POD (3)


Open  0
Stalled  1
View/Report Bugs
Module Version: 2.04   Source   Latest Release: Email-Send-2.201


Email::Send::SMTP - Send Messages using SMTP


  use Email::Send;

  my $mailer = Email::Send->new({mailer => 'SMTP'});
  $mailer->mailer_args([Host => '', ssl => 1])
    if $USE_SSL;


This mailer for Email::Send uses Net::SMTP to send a message with an SMTP server. The first invocation of send requires an SMTP server arguments. Subsequent calls will remember the the first setting until it is reset.

Any arguments passed to send will be passed to Net::SMTP->new(), with some exceptions. username and password, if passed, are used to invoke Net::SMTP->auth() for SASL authentication support. ssl, if set to true, turns on SSL support by using Net::SMTP::SSL.

SMTP can fail for a number of reasons. All return values from this package are true or false. If false, sending has failed. If true, send succeeded. The return values are Return::Value objects, however, and contain more information on just what went wrong.

Here is an example of dealing with failure.

  my $return = send SMTP => $message, 'localhost';
  die "$return" if ! $return;

The stringified version of the return value will have the text of the error. In a conditional, a failure will evaluate to false.

Here's an example of dealing with success. It is the case that some email addresses may not succeed but others will. In this case, the return value's bad property is set to a list of bad addresses.

  my $return = send SMTP => $message, 'localhost';

  if ( $return ) {
      my @bad = @{ $return->prop('bad') };
      warn "Failed to send to: " . join ', ', @bad
        if @bad;

For more information on these return values, see Return::Value.


Email::Send, Net::SMTP, Net::SMTP::SSL, Email::Address, Return::Value, perl.


Casey West, <>.


  Copyright (c) 2004 Casey West.  All rights reserved.
  This module is free software; you can redistribute it and/or modify it
  under the same terms as Perl itself.
syntax highlighting: