zealf has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys, can some advise me on how to format HTML within a posted email using MIME lite?

Essentially I am passing form details from one page to a verify email. On this email I want to format some basic HTML. I want to pass form variables from the email and submit them back onto my site. A basic verification without a date base.

The P1 tags are set up in my css

here is my code

#!/usr/bin/perl use strict; use warnings; use diagnostics; use CGI qw(:standard); use MIME::Lite; use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX=1024 * 100; # max 100K posts my $organisers_name= param('organisers_name'); my $organisers_address= param('organisers_address'); my $organisers_homeN= param('organisers_homeN'); my $organisers_mobile= param('organisers_mobile'); my $organisers_email= param('organisers_email'); my $prefered_contact= param('prefered_contact'); my $brides_name= param('brides_name'); my $brides_number= param('brides_number'); my $wedding_date= param('wedding_date'); my $bride_organiser= param('bride_organiser'); my $suprise= param('suprise'); my $msg = MIME::Lite->new( To =>$organisers_email, Subject =>'Verify3', Type =>'multipart/related' ); $msg->attach( Type => 'text/html', Data => '<BODY> <FORM METHOD="post" ACTION="bookings3.cgi" enc +type="application/x-www-form-urlencoded"> <INPUT TYPE="hidden" NAME="organisers_name" VA +LUE="$organisers_name"> <INPUT TYPE="hidden" NAME="organisers_address" + VALUE="$organisers_address"> <INPUT TYPE="hidden" NAME="organisers_homeN" V +ALUE="$organisers_homeN"> <INPUT TYPE="hidden" NAME="organisers_mobile" +VALUE="$organisers_mobile"> <INPUT TYPE="hidden" NAME="organisers_email" V +ALUE="$organisers_email"> <INPUT TYPE="hidden" NAME="prefered_contact" V +ALUE="$prefered_contact"> <INPUT TYPE="hidden" NAME="brides_name" VALUE= +"$brides_name"> <INPUT TYPE="hidden" NAME="brides_number" VALU +E="$brides_number"> <INPUT TYPE="hidden" NAME="wedding_date" VALUE +="$wedding_date"> <INPUT TYPE="hidden" NAME="bride_organiser" VA +LUE="$bride_organiser"> <INPUT TYPE="hidden" NAME="suprise" VALUE="$su +prise"> <INPUT TYPE="submit" VALUE="Proceed to Step 3" +> </FORM> <hr> <h1>O Name</h1> <p>$organisers_name<br> <hr> <h1>O Address</h1> <p>$organisers_address<br> <hr> <h1>O HomePh</h1> <p>$organisers_homeN<br> <hr> <h1>O Mobile</h1> <p>$organisers_mobile<br> <hr> <h1>O email</h1> <p>$organisers_email<br> <hr> <h1>O contact</h1> <p>$prefered_contact<br> <hr> <h1>B Name</h1> <p>$brides_name<br> <hr> <h1>B Number</h1> <p>$brides_number<br> <hr> <h1>B date</h1> <p1>$wedding_date<br> <hr> <h1>B Organiser Check</h1> <p1>$bride_organiser<br> <hr> <h1>B Suprise</h1> <p>$suprise<br> <hr> </BODY>', ); $msg->send; print header(-type=>'text/html'); print <<EOF ; <html> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" > <title>$organisers_name Hens party with The Man in the Charcoal Suit b +ooking page</title> <link rel="stylesheet" type="text/css" href="../web_layout.css" > </head> <body> <div id="everything1"> <div id="top_text"> </div> <div id="left"> <div id="navcontainer"> <ul id="navlist"> <li><a href="../index.html"><img src="../images/Logo_p +ic.jpg" width="70" height="176" border="0"></a></li> <br> <li><a><img src="../images/icons/bookings.jpg" width=" +70" height="70" border="0" hspace="0"></a></li> <li><a href="../bookings.html">Booking office</a></li> <br> <li><a href="../comments.html"><img src="../images/ico +ns/comments.jpg" width="70" height="70" border="0" hspace="0"></a></l +i> <li><a href="../comments.html">Testimonials</a></li> <br> <li><a href="../contact.html"><img src="../images/icon +s/contact.jpg" width="70" height="70" border="0" hspace="0"></a></li> <li><a href="../contact.html">Contact Us</a></li> </ul> </div> </div> <div id="side_pic"></div> <div id="main1"> <img src="../images/booking_steps/step2.jpg" align="right"> <br> <p1><b1>So far so good $organisers_name.</b1><br><br> <p1>Now while leaving this window, open a new window and check you +r email. <br><br> <b1>Find the CLICK HERE LINK</b1> <br> <p1>And click it to proceed to the next step.<p1> <br><br> <p1>If you do not receive the email:<br><br> <p1>1. Click the back button and verify your email address then pr +oceed as last time.<br><br> <p1>2. If you do not receive the email again verify your email's j +unk setting or junk folder.<br> <FORM> <INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true; +"> </FORM> </div> </div> </body> </html> EOF exit ;

Replies are listed 'Best First'.
Re: MIME lite
by marto (Cardinal) on May 14, 2010 at 13:22 UTC

    You already have an existing thread with this same question. Why are you reposting? What doesn't work? You need to put some effort into your posts. See How do I post a question effectively?.

    Having a form in an HTML email is perhaps not wise. Look at your form action? bookings3.cgi isn't going to be resolvable by the email client. Why not just email them a link (perhaps with some unique identifier) so they can either click it or if they don't accept HTML email, copy and paste it into the browser address bar.

      Thanks for your reply.

      Your right in one respect that I have post questions on MIME while I was learning how to construct it.

      Corion also point out the MIME page, which is what I used to construct what I have learnt so far.

      As limited as I am, learning is slow and I do try to only resort to asking questions on SoPW as a last resort.

      The MIME Lite resource page leaves out some cruical explaination on some stuff. It is all there but I guess it is written for users that have intermediate knowledge.

      The missing part in my sricpt was the Data => qq{ which I had originally used but some reason change to Data => ' which changes the HTML tags to string only.

        Don't get me wrong, I want you to post, however since you already have a thread on this topic you could have posted there rather than start a new one. Please take onboard the other issues raised with your code.

        Note that the MIME::Lite documentation is specific to the module, it doesn't cover basic perl. For that you should check out:

        Thanks

Re: MIME lite
by fullermd (Vicar) on May 14, 2010 at 13:25 UTC

    Well, there are two obvious problems with what you have there.

    The first is that the form action isn't going to mean anything as a relative URL in an email. You'll have to have a full URL there for it to have a chance of getting to your site (how can it know where your site is?)

    The second is that you're passing the email body as a single-quoted string, so none of those variables are going to be interpolated. Maybe you should use a heredoc instead.

    There are other weirdnesses (like what is that javascript 'back' function supposed to do in a mail client?), but those two are the obvious "this can't work" bits.

Re: MIME lite
by Corion (Patriarch) on May 14, 2010 at 13:18 UTC

    Where exactly is your problem? MIME::Lite also shows how to send HTML and how to include the necessary prerequisites like images as well.