in reply to Re: Email Formatting
in thread Email Formatting

Hello:

I tried the format which you provided to me as a link to read on.

When I run my script, I receive the following message:
Global symbol "$text" requires explicit package name

Here is the what I did with the code:
#@ SEND_CONFIRMATION_EMAIL sub send_confirmation_email { my %mail = ( From => "info\@summitwebcrafters.com", # YOU SHOULD CHA +NGE THIS! To => $email, Subject => "Junior Program Registration Form Submitted", Message => "" ); my $page; $mail{Message} = <<EOF; Thank you for your inquiry. A tennis staff member will reply to you w +ithin 24 hours. This is the information you submitted. $text = "$name\n$memberid\n$phone"; format STDOUT = Text: ^* $text ~~ ^* $text . EOF sendmail (%mail) or $page .= p (escapeHTML ("Oops, failure sending mail to $mai +l{To}")); return (defined ($page) ? $page : ""); } #@ SEND_CONFIRMATION_EMAIL


Any ideas of what I did wrong? Thank you for any help in advance.

Replies are listed 'Best First'.
Re^3: Email Formatting
by jhourcle (Prior) on Mar 30, 2005 at 16:32 UTC

    When you're working under use strict; (which is a good thing), you need to let Perl know when you're starting the use of a new variable, by declaring it with my or our, or using use vars. In your case, the problem is actually more subtle, as you're using <<EOF which tells Perl that what follows is to be a string until it sees EOF on a line by itself.

    You'll also need to move the format call to whatever is sending the message to the sendmail. (as it works on filehandles... see the documentation on write ... I apologize, as I probably should have explained it better -- (if we compare 'write' to 'printf', there's no function equivalent to a 'write' version of 'sprintf' that I know of))

    However, I'm more surprised that you said that lining up the text in the code didn't result in them being lined up in the e-mail. It's possible that the sendmail() function that you're using may be corrupting something, or not sending the message as plain text. If so, no matter how much work you do to get it looking pretty as plain text, something else is mangling it.