PDA

View Full Version : HTML Emails


unconnected
06-24-2002, 12:12 AM
Is there anything special that I have to do to send out HTML emails via sendmail?

I have a script for an opt-in emails lists, but I can't get it to send the confirmation email as an html email, or at least I can't get the recipient to interpret it as an HTML email, it just inteprets it as a normal email and shows a bunch of code ..


Do I need a special program? Do I need a special tag or what?

Any helps is appreciated..

thanks

Wilbo
06-24-2002, 12:28 AM
You need a special program and there are none that are free or low cost as far as I know.

unconnected
06-24-2002, 01:13 AM
Any idea on where I would get a program like that?
I have one now that sends html emails out to email list, but I need a program that will take the signup and send back html emails as confirmation emails..

SexySites
06-24-2002, 04:48 AM
surely there is some tutorial around to show you how to do this, i wouldnt have thoguht that using a special program is necessary

laters,
Chris

zergtant
06-24-2002, 04:56 AM
Originally posted by unconnected
Any idea on where I would get a program like that?
I have one now that sends html emails out to email list, but I need a program that will take the signup and send back html emails as confirmation emails..
do you mean you want a script in the site like php or asp,??

Undutchable
06-24-2002, 04:56 AM
It can't be hard.

THink of this: The email that you receive is simply plain text - it has a header and a body. Somewhere within either the header or body there is a specification that denotes the email as HTML mail. Its not a matter of what program to use, its a matter of what code to send.

What i suggest is to save a HTML mail as txt and study the code, experiment in Outlook till u find what u need and voila :)

wd-
06-24-2002, 05:04 AM
of course it's not hard..
it's one line when communicating with the smtp sever
"Plain/Text" or "HTML" if you're script can't change this, i suggest finding another one, because it's useless ;)

porntowers.com
06-24-2002, 05:05 AM
Hi,

Simply write a script in perl (or what ever language suits your taste/needs) that prints the html header via a pipe to sendmail. example:


my $mailprogram = "path/to/sendmail -t -n"; # Set the path of mail program

open (MAIL,"|$mailprogram") or die "Cannot open $mailprogram";
print MAIL "Return-Path: whatever@hm.com\n";
print MAIL "To:";
print MAIL;# Default '$_' var contains email address
print MAIL;# Prints default $_ variable (has the value each line in the emaillist file)
print MAIL "\n";
print MAIL "From: whatever@domain.com\n";
print MAIL "Reply-to: whatever@domain.com\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-type:text/html\n\n";
print MAIL $body
... # WHATEVER OTHER CODE YOU WISH TO INCLUDE
close(MAIL);

# Note this code is under the impression that you are looping through a file or database containing the email addresses this is why the 'To:' line being printed is proceeded by a blank print statement.


$body is the variable of the message you are sending $subject is the subject etc. you get the idea.

The header that sendmail needs to send so email clients recognize the email as being HTML is "Content-type:text/html\n" keep in mind all headers need to have a proceeding new line (\n)
Check out some books on CGI or some tutorials on the web if you need any specifics and more in depth examples.

porntowers.com
06-24-2002, 05:18 AM
Oh,
The body line needed to read:
print MAIL "$body";

evilc
06-24-2002, 11:01 AM
Originally posted by Funkmaster
It can't be hard.


What i suggest is to save a HTML mail as txt and study the code, experiment in Outlook till u find what u need and voila :)


"Give a man a fish, he'll eat for a day!
Teach him to fish, He'll eat for a lifetime"

:cool:

unconnected
06-24-2002, 02:50 PM
ok, none of that is working..
this is what my function looks like for sending confirmation emails

open (MESSAGE, "$message");
flock(MESSAGE, 2);
@message=<MESSAGE>;
flock(MESSAGE, 8);
close (MESSAGE);

open (MAIL, "| $mailprogram $email");
print MAIL "Reply-to: $adminemail\n";
print MAIL "From: $adminemail\n";
print MAIL "To: $email\n";
print MAIL "Subject: Thank you for Subscribing for Free Porn!\n\n";

print MAIL "Content-type:text/html\n\n";
print MAIL "@message";
print MAIL "Visit the web page link belown to confirm your FREE Subscription, and we will send you your first email jam packs FULL of free porn!\n";
print MAIL "$confirmcgi?$email&$affiliate&$secretcode\n\n";

print MAIL "IMPORTANT: To receive your Free Email Newsletter you must first\n";
print MAIL "confirm your subscription by clicking on the Web page link\n\n";

close MAIL;

basically exactly how you specified with a few modifications..
but it is still sending me Text emails filled with HTML code instead of HTML emails..
Can you see anything wrong?

porntowers.com
06-24-2002, 03:00 PM
That is because you specified 2 new lines after the subject and before the content-type header. There cannot be 2 new lines before any element to be contained within the header or it will not be included, and in this case due to the absence of any Content-type header, it will be assumed to be plain text. In fact, a rewrite rule in sendmail will actually add the header: Content-type: text/plain on most sendmail.cf files.

porntowers.com
06-24-2002, 03:04 PM
Oh, one last thing: If you have 2 new lines anytime before the end of a header, the proceeding text is automatically assumed to be part of the body.

unconnected
06-24-2002, 03:22 PM
Wow!
well you just became my new center of worship for the week..
Thanks a bunch for that..

porntowers.com
06-24-2002, 03:27 PM
No problem! :D

Zatlther
06-24-2002, 06:51 PM
Originally posted by porntowers.com
That is because you specified 2 new lines after the subject and before the content-type header. There cannot be 2 new lines before any element to be contained within the header or it will not be included, and in this case due to the absence of any Content-type header, it will be assumed to be plain text. In fact, a rewrite rule in sendmail will actually add the header: Content-type: text/plain on most sendmail.cf files.


I vote that you get elevated instantly to guru status. Damn you're good. :D

porntowers.com
06-24-2002, 08:08 PM
Shucks. I think I'm blushing :embarrase