EasyMail is a Perl Send Mail Interface.
SYNOPSIS
use EasyMail;
if(defined(&EasyMail::foo)){
print "lib is included";
}else{
print "lib is not included";
}
my $email_from = {'email'=>'test@adways.net', 'name'=>'Test'};
my $email_to = 'receiver@adways.net';
# $email_name_pair is a variable specify a email and name # $name can be undef,set $name=undef if $name eq '' # $email_name_pair can be a string # A: "$email" # B: "$name $email" if not A # C: "$email $name" if not A,B # D: ""$name"" if not A,B,C # E: "$name" if not A,B,C,D # $email can be a array_ref # A: [$email,$name] # B: [$name,$email] if not A # $email can be a hash_ref # {email=>$email,name=>$name}
my $email_cc = $email_to;
my $email_bcc = [];
my $ra_filters = ['adways.net'];
my $file = {
'file_path' => '/usr/local/src/test.txt',
#path to file
'file_bin' => undef,
#binary content of file
'file_name' => undef,
#file name
'content_type' => undef,
#content type
'content_id' => undef
#content_id, when u wanna embed picture in html email u need it
# the rule of $file # 1,you "must and can only" set one of file_path and file_bin,or will throw an exception # 2,if file_name set, {file_name}=file_name # 3,if file_name not set and file_path set,then {file_name} will be generate by file_path # 4,if file_name not set and file_path not set and content_id set,then no {file_name} # 5,if content_type setŒthen {content_type}=content_type # 6,if content_type not set and {file_name} setŒthen {content_type} will be generate by {file_name} # 7,if content_id set,then consider this file as part of multi_related structureŒelse if content_id not set then consider this file as part of multi_mixed structure };
my $mail = {
'sender_type' => 'SMTPAUTHLOGIN',
# SENDMAIL | SMTPAUTHLOGIN | SMTPAUTHPLAIN | SMTPAUTHNONE
# default is 'SENDMAIL'
'smtp_host' => '127.0.0.1',
# smtp host address default is 127.0.0.1 (if sender is smtp)
'smtp_port' => 25,
# smtp host port (if sender is smtp)
'smtp_usr' => 'admin',
# smtp author usr name (if needed)
'smtp_pass' => 'password',
# smtp author usr pass (if needed)
'sendmail_path' => '/usr/sbin',
# the path of sendmail, default is 'sendmail'(if needed)
'type' => 'txt',
# can be 'html' 'plain' 'txt' 'text' default is 'plain'
# 'txt' 'text' is alias for 'plain'
# the recomend way you set mail as plain text mail is set it 'plain'
'subject' => 'Test Mail',
# the mail subject, default is 'No Subject'
'body' => 'This is a test.',
# the text content of mail, default is ''
'files' => $file,
# files to be attach to the mail files=>[$file,$file,..], default is []
'from' => $email_from,
# $email_name_pair
'to' => $email_to,
# $email_name_pair || [$email_name_pair,$email_name_pair,..], default is []
'cc' => $email_cc,
# $email_name_pair || [$email_name_pair,$email_name_pair,..], default is []
'bcc' => $email_bcc,
# $email_name_pair || [$email_name_pair,$email_name_pair,..], default is []
'mail_filter' => $ra_filters,
# [$email_filter, $email_filter, ..], default is []
# email_filter: only allow specified email to send ( for debug use)
'return_path' => '/tmp/failmail',
#sendmail to this address if sendmail fail ,default is not set
'src_encoding' => 'utf8',
#source mail encoding
'dst' => 'un'
# 'cn' || 'un' || 'jp'
# 'cn' for gb2312 encoding, 'un' for utf8 encoding, 'jp' for iso-2022-jp encoding
# extra rules: # from is must set # to and cc must contains more than one valid email # if (input is all unicode or input is all ascii){ # src_encoding can be not set # }else{ # src_encoding must set # } # dst must set # in to cc bcc, [$email,$email] is parse as two receiver email
};
EasyMail::sendmail($mail);
The synopsis above only lists the major methods and parameters.
Product's homepage
Requirements:
· Perl