472,988 Members | 3,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 software developers and data experts.

change script to send html email

9
hello all,

i need help modifying a small perl script that sends an email after a form is submitted.
i need to be able to receive the email in html format, but my knwoledge of perl is very poor.

please any help at this moment would be fantastic.

thank you.

here is my script:
Expand|Select|Wrap|Line Numbers
  1. l#!/usr/bin/perl -w
  2.  
  3. use Net::SMTP;
  4. use CGI;
  5.  
  6. my $cgi = new CGI;
  7.  
  8. sub send_mail 
  9.  
  10. {
  11.     my $to = $_[0];
  12.     my $subject = $_[1];
  13.     my $body = $_[2];
  14.      my $from = $_[3];
  15.  
  16.     my $smtp;
  17.  
  18. if (not $smtp = Net::SMTP->new('mail.server.com', Port => 25, Debug => 1)) 
  19. {
  20.     die "Could not connect to server\n";
  21. }
  22.  
  23. $smtp->mail($from . "\n");
  24.  
  25. my @recepients = split(/,/, $to);
  26.  
  27. foreach my $recp (@recepients) 
  28. {
  29.     $smtp->to($recp . "\n");
  30. }
  31.  
  32. $smtp->data();
  33. $smtp->datasend("From: " . $from . "\n");
  34. $smtp->datasend("To: " . $to . "\n");
  35. $smtp->datasend("Subject: " . $subject . "\n");
  36. $smtp->datasend("\n");
  37.  
  38. $smtp->datasend($body . "\n");
  39. $smtp->dataend();
  40. $smtp->quit;
  41. }
  42. # Send away!
  43. &send_mail($cgi->param('to'), $cgi->param('subject'), $cgi->param('body'), $cgi->param('from'));
  44.  
  45. print $cgi->header;
  46. print '<html><body>Your e-mail has been sent</body></html>';
  47.  
Jun 17 '08 #1
1 1894
gpraghuram
1,275 Expert 1GB
You can use MIME::Lite to do this
See this sample code
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use MIME::Lite;
  3.  
  4. # SendTo email id
  5. my $to_id = 'yourid@mail.com';
  6.  
  7. # create a new MIME Lite based email
  8. my $msg = MIME::Lite->new
  9. (
  10. Subject => "HTML Mail",
  11. From    => 'yyy@zzz.com',
  12. To      => $to_id,
  13. Type    => 'text/html',
  14. Data    => '<H1>Hello</H1><br>This is sample html mail.<br>'
  15. );
  16.  
  17. $msg->send();
  18.  
  19.  
Raghu
Jun 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jeff Dunnett | last post by:
Hello, I have written the following HTML Form: <html><head><title>Survey</title></head> <body bgcolor="black" text="white" link="#f6b580" vlink="#c0c0ff"> <img src="logo.gif" width="324"...
16
by: Fox | last post by:
I merged and modified these script which work perfectly fine as long as I use server.execute to access the VBS part (which is itself in another ASP file). When these I use a session variable to...
3
by: bigoxygen | last post by:
Hi. I have a list that is similar to this: -Evaluation +test +test -Students +test I would like to change the "-" bullet only, but I cannot. My
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
5
by: Iver Erling Årva | last post by:
This works: Main window: <html> <head> <title>Untitled Document</title> <script> function openSub(){ window.open("Printwindow.htm","pw","height=200px, width=300px, left=300px, top=300px")
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
2
chunk1978
by: chunk1978 | last post by:
i wrote a custom PHP script last year and everything worked perfectly... recently my webserver upgraded to PHP 5 and now my script doesn't work properly. what the script does is: users fill out...
1
by: toretto | last post by:
Hello, I have a script php that I use on my website to permit visitors to send me some email with some data, this is the html table code: <table width="730" border="0" cellpadding="0"...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.