How to Send Email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramyaamar
    New Member
    • Feb 2007
    • 6

    How to Send Email

    Hii
    I am Beginner to perl..I need to send a notification mail to a user tht is when a person excutes the program.....(me an automatically a mail should be sent to a id) i searched in the net... i came to know should install Mail::Mailer or sender.pm or lite packages... i dont know which one to install and how to write the program ??? an idea....Thanks in advance!
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    you probably don't need to install anything if there is already sendmail or qmail or other email application installed on the server. Just pipe the email out to one of those applications. Or use the MIME::Lite module. It may have to be installed though.

    Comment

    • davidiwharper
      New Member
      • Mar 2007
      • 20

      #3
      I'm a beginner too, but this is the code I've been taught -- for use with a UNIX/Linux environment:

      Code:
      #!/usr/bin/perl
      #
      # Email program - sends message to administrator
      #
      
      my $sendmail = '/usr/sbin/sendmail'; # this is different on some systems, use "whereis sendmail" to find the exact location
      my $destination = 'admin@somewhere.com.au';
      my $sender = 'admin@somewhere-else.com.au';
      
      # send the email
      
      open MAIL, "|$sendmail -oi -t" or die "Can't open pipe to Sendmail: $!\n";
      
      print MAIL <<"EOF";
      To: $destination
      From: $sender
      Subject: This is the subject line
      
      Hello there,
      
      This is a message
      
      Thank you for your assistance.
      
      Regards,
      David
      
      EOF
      # remember that ONLY "EOF" can show on the line
      
      close MAIL or die "Can't close pipe to Sendmail: $!\n";
      
      # end of program
      David

      Comment

      Working...