Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Here is a pretty generic implementation of a program to mail html and text to a small list.
#!/usr/bin/perl use warnings; use strict; use MIME::Lite; use Net::SMTP; my @keys = qw(email name street city zip phone); my %recipients; my @fields; my $email; while(<DATA>){ @fields=(); ($email,@fields) = chomp && split(/\Q|\E/); # print "$email -> @fields\n"; $recipients{$email} = \@fields; } foreach my $key (keys %recipients){print "$key -> $recipients{$key}\n" +}; #for(keys %recipients){ #print "$_ has ",scalar @{$recipients{$_}}," stations and they are:\n" +; #for(@{$recipients{$_}}){ #print <<INFO; #Name: $_->[0] #Email: $_->[1] #Street 1: $_->[2] #City: i $_->[3] #State: $_->[4] #Zip: $_->[5] #Phone: $_->[6] #INFO #} #} #=head1 my $fromaddress = 'zentara@stream.net'; foreach my $recipient (keys %recipients){ my $smtp = Net::SMTP ->new('zentara.zen.net'); $smtp->mail('you@yourdomain'); #use your mail name $smtp->to('reciever@recieverdomain'); $smtp->data( ); my $msg = MIME::Lite->new( From =>'Joe', To =>'Shmoe', Subject =>'HTML Test', Type =>'multipart/related', ); $msg->attach( Type => 'text/plain', Data => 'HERE IS YOUR HTML PAGE', ); $msg->attach( Type => 'text/html', #Path =>'full_file_name', Path => $0, Disposition => 'attachment', ); # send the message over $smtp->datasend( $msg->as_string() ); # close smtp connection $smtp->dataend(); $smtp->quit; } #=cut __DATA__ zentara@zentara.net|Zboo P. Crumbcake|1234 Main Street|San Francisco|C +A|94124|123-4567 zentara@gypsyfarm.com|Zebar X. Zipwon|3456 Second Ave.|San Francisco|C +A|94131|999-1234 zentara@highstream.net|Xbaz A. Fule|9123 Lost Road|Oakland|CA|97541|43 +1-4312 zentara@localhost|Ybong A. Gong|3456 Wain Street|San Francisco|CA|9413 +1|999-1234

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: How to send nicely formatted emails in Perl? by zentara
in thread How to send nicely formatted emails in Perl? by dr.jekyllandme

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (8)
    As of 2014-12-25 23:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (163 votes), past polls