Help with my first email perl script

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

  1. 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
     
    , Jul 11, 2005
    #1
    1. Advertising

  2. Paul Lalli Guest

    wrote:
    > 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'


    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.

    > 2. How do i attach attachments?


    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

    >
    > 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
     
    Paul Lalli, Jul 11, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,590
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,861
  3. pj
    Replies:
    3
    Views:
    321
  4. Petterson Mikael

    Execute another perl script from my perl script

    Petterson Mikael, Jan 5, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    153
    Paul Lalli
    Jan 5, 2005
  5. Replies:
    14
    Views:
    212
    Peter J. Holzer
    May 8, 2006
Loading...

Share This Page