Help with my first email perl script

Discussion in 'Perl Misc' started by sanju.shah, Jul 11, 2005.

  1. sanju.shah

    sanju.shah Guest

    After going thru the Active Perl documentation, I am playing with a
    test email script. 2 issues i am facing:

    1. When i get the email - the from & to address does not contain the
    @company - it is only 'shah.com'
    2. How do i attach attachments?

    TIA,

    Regards,
    Sanju

    Script:

    use Net::SMTP;

    $smtp = Net::SMTP->new('mailserver.company.com'); # connect to an SMTP
    server
    $smtp->mail( '' ); # use the sender's address here
    $smtp->to(''); # recipient's address
    $smtp->data(); # Start the mail

    # Send the header.
    $smtp->datasend("To: \n");
    $smtp->datasend("From: \n");
    $smtp->datasend("\n");

    # Send the body.
    $smtp->datasend("Hello, World!\n");
    $smtp->dataend(); # Finish sending the mail
    $smtp->quit; # Close the SMTP connection
     
    sanju.shah, Jul 11, 2005
    #1
    1. Advertisements

  2. sanju.shah

    Paul Lalli Guest

    You have failed to 'use strict;' and 'use warnings;'. Either of these
    statements would have told you what caused this error.

    Have you read the posting guidelines for this newsgroup? They contain
    helpful hints like that which tell you how you can best help yourself,
    and how to best help us help you.
    The docs for Net::SMTP specify that this module is for those who are
    familiar with the SMTP RFC. If you are not, you would be better off
    using a higher-level mailing module, which provides interfaces for
    things such as attachments. You could search CPAN for such a module
    (perhaps Mail::Mailer or Mail::Internet might help?) or you could (and
    should have) checked the Perl FAQ:
    perldoc -q attachment

    <code remains below for reference>

    Paul Lalli
     
    Paul Lalli, Jul 11, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.