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

Net::SMTP::OneLiner - extension that polutes the local namespace with a send_mail() function.

A brief example

    use Net::SMTP::OneLiner;

    my $from = 'me@mydomain.tld';
    my $to   = [qw(some@targ.tld one@targ.tld)];
    my $cc   = [qw(some@targ.tld one@targ.tld)];
    my $bcc  = [qw(some@targ.tld one@targ.tld)];
    my $subj = "The Subject";
    my $msg  = "The Message";
    my $labl = { 'me@mydomain.tld' => "My RealName", 'one@targ.tld' => "Their realname" };

     
    # Examples:

    send_mail($from, $to, $subj, $msg);
    send_mail($from, $to, $subj, $msg, $cc);
    send_mail($from, $to, $subj, $msg, undef, $bcc);
    send_mail($from, $to, $subj, $msg, $cc, $bcc, $labl);
    send_mail($from, $to, $subj, $msg, undef, undef, $labl);

    send_mail('me@domain', ['you@domain'], "heyya there", "supz!?!?");

    # The simplest way:

    send_mail('me@domain', 'you@domain', "heyya there", "supz!?!?");

    # At this time, the mail server, must be the localhost.

VARS

Hirosi Taguti requested a method for changing the SMTP host. I provided that and a few other variables. The values listed are the defaults.

$Net::SMTP::OneLiner::HOSTNAME = "localhost"

The hostname of the SMTP server you wish to use. This takes all the arguments you'd expect a IO::Socket::INET object to take.

$Net::SMTP::OneLiner::PORT = 25;

The port on the smtp server you wish to use. If you use this, do not set the port in $Net::SMTP::OneLiner::HOSTNAME or you will create bugs for yourself.

$Net::SMTP::OneLiner::EHLO = "localhost"

The hostname you wish to send in the EHLO greeting. It normally doesn't matter what you put here -- even if you change the HOSTNAME.

$Net::SMTP::OneLiner::DEBUG = 0

If this is set to true, OneLiner will tell Net::SMTP to spew forth many lines of debugging info.

$Net::SMTP::OneLiner::TIMEO = 20

Use this to change the communication timeout (in seconds) with the SMTP host.

Bugs

Please report bugs immediately! The author has not tested this module worth a lick -- expecting it to work just fine. If this is not the case, he would like to know, so he can fix it.

Bad BCC: Bug

BCC: recipients were not working at all! Thanks to Stephen Thomas for finding this bug.

AUTHOR

Paul Miller <paul@cpan.org>

I am using this software in my own projects... If you find bugs, please please please let me know. :) Actually, let me know if you find it handy at all. Half the fun of releasing this stuff is knowing that people use it.

COPYRIGHT

Copyright (c) 2007 Paul Miller -- LGPL [attached]

SEE ALSO

perl(1)