in reply to Email Formatting

If you want the text to line up in columns, is there any reason why you don't have the stuff in the message lined up?

Member Name: $name Member ID: $memberid Telephone: $phone Email Address: $email Guest Name(s): $guest Event Date: $eventdate Events: $event Payment: $payment Message: $message

or

Member Name: $name Member ID: $memberid Telephone: $phone Email Address: $email Guest Name(s): $guest Event Date: $eventdate Events: $event Payment: $payment Message: $message

Of course, you'd want to make sure that all of the stuff was properly wrapped if it was too long of a string, etc. But if those items are verified to be short, it's not a problem. (I'm assuming $message isn't.... for that, look at format and write)

Installing new modules just for this simple task would be overkill, if the builtin stuff meets the needs, in my opinion.

And um... as you said 'provider'. I hope this isn't for a web page. If it is, return a webpage -- sending to email addresses that were entered on a web page is just asking for trouble.

Replies are listed 'Best First'.
Re^2: Email Formatting
by b310 (Scribe) on Mar 30, 2005 at 13:53 UTC
    Hello:

    Thank you for your reply. As you suggested, I tried lining up the text into columns. Actually, I tried both of the formats you suggested. Neither of them worked

    I did some reading on the format link you sent me and it seems that might just be the answer.

    My question, do I place the format code within the body of my email or do I have to do it in the beginning of my script.

    Thank you in advance for your help.
Re^2: Email Formatting
by b310 (Scribe) on Mar 30, 2005 at 14:03 UTC
    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.

      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.