Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

how do i send an email with perl in window system

( #33488=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Sep 21, 2000 at 18:20 UTC
Q&A  > mail and news


Description:

Trying to send email; system is Windows. In particular, I'd like to use the Yahoo email service to send the mail. Any help appreciated.

Answer: how do i send an email with perl in window system
contributed by sago

Please see the below two programs to send mail through perl using activeperl on windows.

The first uses Mail::Sendmail and the second uses MIME::Lite.

use Mail::Sendmail; my $MailFrom = 'test@gmail.com'; my $to_list = 'john@gmail.com'; my $cc_list = 'frank@yahoo.com'; my $subject = "hello test"; my $message = "This email was generated automatically.\n"; sendmail( Smtp => 'mailtest.gmail.com', From => $MailFrom, To => $to_list, Cc => $cc_list, Subject => $subject, Message => $message, );
use MIME::Lite; MIME::Lite->send('smtp', "mailtesthub.gmail.com", Timeout=>90); my $MailFrom = 'test@gmail.com'; my $to_list = 'john@gmail.com'; my $cc_list = 'frank@yahoo.com'; my $subject = "hello test"; my $message = "This email was generated automatically."; my $msg = MIME::Lite->new( From => $MailFrom, To => $to_list, Cc => $cc_list, Subject => $subject, Type => 'TEXT', Encoding => '7bit', Data => $message, ); $msg->send()
Answer: how do i send an email with perl in window system
contributed by iguane

MIME::Lite works on Windows. If you have a sendmail program installed, you can use that:

MIME:Lite->send( 'sendmail', "d:\\programs\\sendmail.exe" );
Otherwise, you can tell it to use a remote mail server via smtp.
Answer: how do i send an email with perl in window system
contributed by idnopheq

A few non-Perl, Yahoo!-specific things to consider:

  • Sign up in the POP Access and Forwarding section of Options.
  • 'Need Help?' for POP3 access tells you what you need to use this access (server names, etc.)
  • You must authenticate when you send SMTP messages via their service.

As for Perl, TIMTOWTDI. The combination of Mail::Sender (for the SMTP) and Mail::POP3Client (for the authentication) may work with Yahoo! mail without the need for SendMail. Both are available on ActiveState's PPM Package Repository.

Answer: how do i send an email with perl in window system
contributed by Anonymous Monk

When facing similar things, I use the smtp method of Mail::Mailer (which depends on elements of the Net bundle).

The following example sends an e-mail composed from a terminal window. Obviously you'd need to configure the variables to your situation.

use Mail::Mailer; print "\nTo: "; $dest = <>; chomp $dest; print "Subject: "; $subj = <>; chomp $subj; print "\nBody:\n"; $body = <>; $mailer = Mail::Mailer->new( 'smtp', Server => 'pilot.msu.edu' ); $mailer->open( { From => 'Mr Grits <moranjon@pilot.msu.edu>', To => $dest, Subject => $subj, } ) or die "mailer->open failed: $!\n"; print $mailer $body; $mailer->close;

Please (register and) log in if you wish to add an answer



  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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 chanting in the Monastery: (6)
    As of 2015-07-07 06:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (87 votes), past polls