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

Hello great perl monks.I want to send an email from a cgi script with the content as a html page. I removed any and all the spaces before *END* but the same error appears Can't find string terminator "*END*" anywhere before EOF
use CGI ':standard'; use Mail::Sender; my @rel=param ('rel'); my @label=param ('label'); my @config=param ('config'); $sender=new Mail::Sender {smtp=>'server', from=>'cbedreag@yahoo.com'}; $sender->OpenMultipart({to=>'test@hotmail.com',subject=>"Test mail", multipart=>'related'}); $sender->Part({ctype=>'text/html',disposition=>'None', msg-><<'*END*'} +) <html><body><br> <br><center><table border=2><tr><td><h3>Package</h3></td></tr> <tr><td>From</td><td>Diana</td></tr><tr><td>Date</td><td>@date</td></t +r> <tr><td>Relationto</td><td>@rel</td></tr> <tr><td>testing</td><td>@label</td></tr> <tr><td>Const</td><td>@config</td></tr></table></center></body></html> *END* $sender->EndPart("text/html"); $sender->Close();
Thank you!

Replies are listed 'Best First'.
Re: sending email with plaintext and HTML
by Roger (Parson) on Jan 19, 2004 at 13:37 UTC
•Re: sending email with plaintext and HTML
by merlyn (Sage) on Jan 19, 2004 at 14:36 UTC
    You're missing the part of the script where you avoid sending email to merlyn@stonehenge.com.

    I never want HTML email in my inbox, and I know a lot of other people feel the same way. HTML is for web pages, not email.

    Please consider this before you deploy such a script. At least give people a database where they can say "no web in my mail, please".

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: sending email with plaintext and HTML
by gellyfish (Monsignor) on Jan 19, 2004 at 11:16 UTC

    Well it looks like you have a large block of quoted text in a void context that you don't do anything with.

    You should add the text to the message using the msg parameter of the Part() method or use the SendEnc() method to add it separately.

    UPDATE: Okay, I'm either going blind or stupid but I didn't see the here document part of that when I made the reply. The closing token of the here document needs to be flush to the left with no spaces before or after. Personally I would lose the asterisks as well but if it works for you ...

    /J\

Re: sending email with plaintext and HTML
by edoc (Chaplain) on Jan 19, 2004 at 12:21 UTC

    remove any and all spaces before *END*, it needs to be hard against the left, it cannot be indented at all.

    cheers,

    J

      Well, it can, but then you would have to include the same amount of spaces in the quoted string:
      print << ' END'; Text goes here... END
      And to have the actual text indented, you'd have to so some search/replace:
      my $text; ($text = <<' END') =~ s/^\s+//gm; Indented text END

      Arjen