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 |
| |||
| 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."); |
| Sponsored Links |
| |||
| #!/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 | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/perl/2096-simple-email-using-perl.html | |||
| Posted By | For | Type | Date |
| domain email hosting - Simple Email - Using Perl | This thread | Refback | 07-18-2007 09:34 AM |
| email domain hosting - Simple Email - Using Perl | This thread | Refback | 07-18-2007 09:29 AM |
| email hosting - Simple Email - Using Perl | This thread | Refback | 07-18-2007 09:28 AM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Interview Questions | Sathish Kumar | C# Programming | 56 | 03-21-2008 07:53 AM |
| Simple Alexa Rank Retrieval | Sabari | PHP Programming | 28 | 12-04-2007 06:44 AM |
| simple example for the java concepts | lavanya | Java Programming | 2 | 07-20-2007 06:48 AM |
| How to set Perl Interpreter within perl script | sivaramakrishnan | Perl | 1 | 07-19-2007 06:45 AM |
| Create Simple ShoutBox | spid4r | PHP Programming | 0 | 03-08-2007 11:03 PM |