Forum Moderators: coopster & phranque

Message Too Old, No Replies

Html Email

         

walker

10:25 am on Sep 1, 2003 (gmt 0)

10+ Year Member



Hi

I am using a piece of code to send emails, what I require is the ability to add a graphic letter head into the email below is a snippet of the code and where I need to place the HTML code any help would really be appreciated as I currently have a very basic understanding of PERL CGI

# Sending the mail via mailprogram on the server

open (MAIL, "¦$mailprog -t $i") ¦¦ die "Can't open $mailprog!\n";
print MAIL "From: $FORM{'from'}\n";
print MAIL "To: $FORM{'to'}\n";
print MAIL "Subject: $FORM{'subject'}\n";
print MAIL "Cc: $FORM{'cc'}\n";
print MAIL "Bcc: $FORM{'bcc'}";
if ($FORM{'attachment'}) {
print MAIL "\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: MULTIPART/MIXED; BOUNDARY=\"7777777-77777-777777777=:-333333\"";
}
print MAIL "\n\n";
if ($FORM{'attachment'}) {
print MAIL "--7777777-77777-777777777=:-333333\n";
print MAIL "Content-Type: TEXT/PLAIN; charset=US-ASCII\n";
}
print MAIL "\n";
*****NEED TIO ADD GRAPHIC LETTERHEAD****
print MAIL "Name - $FORM{'Name'}\n";
print MAIL "Company - $FORM{'Company'}\n";
print MAIL "Tel - $FORM{'Tel'}\n";
print MAIL "Fax - $FORM{'Fax'}\n";
print MAIL "email - $FORM{'Email'}\n";
print MAIL "\n";

Kind Regards

Rod

Damian

11:17 am on Sep 1, 2003 (gmt 0)

10+ Year Member



Hi Rod,

I think you can just write the html where you now have

*****NEED TIO ADD GRAPHIC LETTERHEAD****

If I'm right, substitute that line by the actual html as below, the 'qq~' notation allows you to use quotes in the fragment which are very common in html.. but you will have to 'escape' any tilde (~)characters in the fragment, meaning you should put a backward slash (\) in front of any tilde that is part of your html.

print MAIL qq~
<html><head></head><body>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua <img src="image.jpg">
~;

<added>

Looking at your snippet again, sorry I made a mistake.. the end of the html should be on the last line of course, so I removed the </body></html> part from my snippet above. Instead add one more line to the bottom of the snippet that closes the html áfter the last part of the html. So , also change

print MAIL "email - $FORM{'Email'}\n";
print MAIL "\n";

to

print MAIL "email - $FORM{'Email'}\n";
print MAIL "\n";
print MAIL qq~ </body></html> ~;

</added>

MonkeeSage

11:35 am on Sep 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Close...

...
print MAIL "\n";
print MAIL <<EndHTML;
<html><head></head><body>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</body></html>
EndHTML

print MAIL "Name - $FORM{'Name'}\n"
...

The "<<EndHTML" means print untill input is "EndHTML", then "EndHTML" on a separate line (with no semi-colen after it) breaks the printing.

Jordan

walker

10:12 am on Sep 2, 2003 (gmt 0)

10+ Year Member



Hi

Thanks for the help so far, unfortunatly with the first example the email simply prints out the lines of code instead of formatting them into HTML

and with the second it fails completly.

Kind Regards

Rod

Any further assistance is really appreciated.