Using NET::SMTP in Perl to send .OFT templates -


i have working perl code fires off email correct email address generic subject , content.

however, whenever new user starts, fire off premade .oft template says need know. .oft stored on our server. wondering there way alter perl code make takes to: uses .oft template make rest of email??

so basically

    $smtp = net::smtp->new('smtp.blah');     $smtp->('no-replay@blah.com');     $smtp->to('$personemail');     $smtp->data();     $smtp->datasend($locationofofttemplate);     $smtp->dataend();     $smtp->quit; 

afaik there no module handling proprietary format. instead, translate standard templating system:

my $template = <<'template'; morning, [% name %]!  today first day @ work. have received universal login credentials:      [% ldap_user %]     [% ldap_pass %]  works authenticating @ web proxy, mail system, jabber , internal services. change password asap: <[% ldap_web %]>  --  yours sincerely, greeting daemon template  use text::xslate qw(); $text = text::xslate->new(syntax => 'tterse')->render_string($template, {     name => 'new bee',     ldap_user => 'nbee',     ldap_pass => 'con-glom-o',     ldap_web => 'http://192.168.0.1:8080/', }); 

use mime toolkit create emails. html/multipart/attachments easy courriel::builder:

use courriel::builder;  $email = build_email(     subject('welcome'),     from('no-reply@example.com'),     to('…'),     plain_body($text), ); 

finally, send using high-level library email::sender gives nice error checking , allows switch out transports - run local delivery testing.

use email::sender::simple qw(sendmail); use email::sender::transport::smtp qw(); use try::tiny;  try {     sendmail(         $email,         {             transport => email::sender::transport::smtp->new({                 host => 'smtp.example.invalid',             })         }     ); } catch {     warn "sending failed: $_"; }; 

Comments