Hi

I seem to be having a problem using variables in the body of an email with Mail::Sender. I am hoping someone has successfully done what I am attempting to do.

First I get data from a html form, then I concatenate the needed values into the message of the email. When I receive the email the body of the email is there, but the values that should be in the first and last name are not displaying. I know the $params variable contains data, because before the an email is sent, the data from $params is used to record data into the database, and it is recording properly.

I am using Catalyst as well.

A Simplified version of the HTML FORM

. . . <form name="rsvp" action="send_confirmation" method="POST"> First Name: <input type="text" name="First"> Last Name: <input type="text" name="Last"> <input type="submit" value="Send"> </form> . . .

PERL

use Mail::Sender; . . . method send_confirmation_email( $params ) { # $params = $c->req-para +ms in the controller, which is passed to this method. my $user_obj = $self->get_user_data(); my $rsvp_email = new Mail::Sender({ smtp => 'smtp-myserver.mydomain.com', from => 'me.person@mydomain.com', }); my $name = $params->{ 'First' } . " " . $params->{ 'Last' }; if($params->{ 'attending' } eq 'Y') { $msg = "<html><body><p>Dear " . $name . ",</p>"; $msg .= qq|<p>Thank you for submitting your RSVP. We will se +nd an informational packet to your home.|; + $rsvp_email->OpenMultipart({ to => $params->{ 'email' }, subject => "RSVP Confirmation", }); $rsvp_email->Part({ ctype => 'text/html', disposition => 'NONE', msg => $msg, }); $rsvp_email->EndPart("text/html"); $rsvp_email->Close; return; } else { $msg = "<html><body><p>Dear " . $name . ",</p>"; $msg .= qq|We are sorry you are unable to attend. Thank you +for notifying us.|; $msg .= "</body></html>"; $rsvp_email->OpenMultipart({ to => $params->{ 'email' }, subject => "RSVP Confirmation", }); $rsvp_email->Part({ ctype => 'text/html', disposition => 'NONE', msg => $msg, }); $rsvp_email->EndPart("text/html"); $rsvp_email->Close; return; }

Any help would be much appreciated.


In reply to Trouble Using Variables in Body of Mail Sender Email by phildeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.