This is a discussion on Simple Email - Using Perl within the Perl forums, part of the Software Development category; hi, simple email function : #!/usr/bin/perl print "Content-type: text/html\n\n"; # Simple Email Function # ($to, $...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| hi, simple email function : #!/usr/bin/perl print "Content-type: text/html\n\n"; # Simple Email Function # ($to, $from, $subject, $message) sub sendEmail { my ($to, $from, $subject, $message) = @_; my $sendmail = '/usr/lib/sendmail'; open(MAIL, "|$sendmail -oi -t"); print MAIL "From: $from\n"; print MAIL "To: $to\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$message\n"; close(MAIL); } sendEmail("ToID\@domain.com", "FromID\@domain.com", "Simple email.", "This is a test of the email function."); |
|
#3
| |||
| |||
| #!/usr/bin/perl use MIME::Lite; use Net::SMTP; ### Adjust sender, recipient and your SMTP mailhost my $from_address = 'FromEmailID@domain.com'; my $to_address = 'ToEmailID@domain.com'; my $mail_host = 'mail.domain.com'; ### Adjust subject and body message my $subject = 'Testing - Perl mail with Attachment'; my $message_body = "Here's the attachment file(s) you wanted "; ### Adjust the filenames my $my_file_gif = '1.gif'; my $your_file_gif = '2.gif'; # my $my_file_zip = '1.zip'; # my $your_file_zip = '2.zip'; ### Create the multipart container $msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ### Add the text message part $msg->attach ( Type => 'TEXT', Data => $message_body ) or die "Error adding the text message part: $!\n"; ### Add the GIF file $msg->attach ( Type => 'image/gif', Path => $my_file_gif, Filename => $your_file_gif, Disposition => 'attachment' ) or die "Error adding $file_gif: $!\n"; ### Send the Message MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send; |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple program help... | hkp819 | C and C++ Programming | 1 | 12-28-2008 07:38 AM |
| Simple URL Variable | jennifergttfrd | PHP Programming | 0 | 12-27-2008 07:45 AM |
| Simple question for PHP | thomasEpand | PHP Programming | 0 | 11-18-2008 10:42 PM |
| How to set Perl Interpreter within perl script | sivaramakrishnan | Perl | 1 | 07-19-2007 05:45 AM |
| Create Simple ShoutBox | spid4r | PHP Programming | 0 | 03-08-2007 10:03 PM |
Our Partners |