Forum Moderators: coopster & phranque

Message Too Old, No Replies

format email data sent from a html form

         

newp

1:07 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



hi,

I have a form the output of which is sent to a email.

I am trying to format the email output so that i can use some html tags in the mail.

If anyone knows how to format the email

thanks,

VectorJ

5:23 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



You need to set the Content-Type header to text/html.

newp

9:23 am on Apr 6, 2004 (gmt 0)

10+ Year Member



i have set the content type to text/html like :

print "Content ype: text/html";

this is added after giving the path for the sendmail

but this only prints the html tags in the mail body

for eg: <b> abc efgd </b>

it does not format the text

can u tell me what is the solution for this

thanks,

lexipixel

1:55 pm on Apr 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure with email, but with HTML output you need the
content type line to have two new lines chars at end.

"Content type: text/html\n\n"

Note the two ("\n") newline chars....

VectorJ

1:59 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



If you're printing directly to sendmail, then I'm not sure how to change the headers in any way other than what you're doing. Maybe try printing the Content-Type: header before the To: header?

I personally use the Mail::Sendmail module, which makes it very easy to set headers.

newp

3:57 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



i tried using the

print MAIL "Content-Type: header \n\n";

but it does not work and i can see this statement printed in the mail

how do i use the sendmail?

VectorJ

4:11 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



I don't recall how to send a header when interfacing directly with sendmail. If something like:

print MAIL "Content-Type: text/html";
print MAIL "To: you@example.com";
print MAIL "From: me@examnple.com";
print MAIL "Subject: Hi\n\n";
print MAIL $email;

doesn't work, then I suggest using the Mail::Sendmail module:

use Mail::Sendmail;

$message = '<html><b>This is the text of your email</b></html>';

%mail = ('To' => 'whoever@example.com',
'From' => 'My Name <someone@example.com>',
'Content-Type' => 'text/html; charset="iso-8859-1"',
'Subject' => 'Newsletter',
'Message' => $message);

sendmail(%mail);