473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 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 1909
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.