phildeman has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trouble Using Variables in Body of Mail Sender Email
by GotToBTru (Prior) on Apr 13, 2016 at 12:49 UTC | |
by stevieb (Canon) on Apr 13, 2016 at 13:01 UTC | |
by phildeman (Scribe) on Apr 13, 2016 at 20:08 UTC |