I would like to be able to send a html file as the message part, using sendmail. Is this possible?
open (MAIL,"|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $email\n";
print MAIL "From: $fromsender\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Message: $htmlfile\n";
close (MAIL);
$mailprog $email $fromsender $subject and $htmlfile are defined in the first section of the script.
I could put the html code in the script but would rather have to change the html file than the cgi script.
First thing is you'll have to print to MAIL Content-Type: text/html as part of the header, meaning before the first blank line (\n\n). Second, it just sounds like you want a template?
-- template.html -- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
I'm not a pro at this and have never used "my" for anything before. I got lost when you used ($html_start, $html_end) = Split /<!-- %CONTENT% -->/, <TEMPL>, 2;
Why do I have to split anything? If I split the CONTENT out then how do I send the CONTENT to Sendmail?
The split divides the template up into two pieces: everything before <!-- %CONTENT% --> is assigned to $html_start, and everything after it is assigned to $html_end. This gives you a sort of HTML header and footer to surround your content making it a complete and valid page.
The my declares a variable to local (lexically) to the enclosing block. When using strict in your program, which is highly recommend to the point of almost being a rule, you must declare any variable you use, which is a good idea to do anyway.
I follow along. I tried the code that you sent and the e-mail gets sent. The only problem is I get the code of the html page in the e-mail and not the displayed page.
I want this to work as a autoresponder. I get e-mails all the time that have pictures and background colors. This is what I'm trying to accomplish.
This is the current version that I'm working with. I tried the other and couldn't get it to work. I missing something and don't know what it is.
I really don't what to use a template for this operation. I'm trying to send html code to show my advertizement.
Script in the program right now. I used this just to see if I could get it to work and it doesn't.
open (MAIL,"|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $email\n";
print MAIL "From: $fromsender\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Mime-Version: 1.0\n";
print MAIL "Content-type: text/html\n\n";
print MAIL "\n\n";
print MAIL "<b>Hello,</b><br>\n";
print MAIL "<i>This is a test to see if this works</i>\n";
print MAIL "\n\n";
close (MAIL);
You have a blank line, and thus the ending of your header, after the subject. There should be only one new line there so the mime-version and content-type are included in the header.
My latest attemp didn't work. I keep getting the code in the e-mail.
I went back to what you showed me earlier.
my $html_start;
my $html_end;
{ undef local $/;
open (TEMPL, "$message") || die "Can't Open $message: $!\n";
flock (TEMPL, LOCK_SH);
($html_start, $html_end) = split /<!-- %CONTENT% -->/, <TEMPL>, 2;
close (TEMPL);
}
################
if ($mail eq'1'){
open (MAIL,"|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $email\n";
print MAIL "From: $fromsender\n";
print MAIL "Subject: $subject\n\n";
print MAIL $html_start, "Message: $message1", $html_end;
}
close (MAIL);
$mail is set to 1 earlier in the script. I have attached the script for your viewing. I'm using featureprice.com for my hosting. Could there be something wrong with sendmail?
print MAIL "To: $email\n";
print MAIL "From: $fromsender\n";
print MAIL "Subject: $subject\n"; print MAIL "Content-Type: text/html\n\n";
print MAIL $html_start, "Message: $message1", $html_end;
Did that. Still does not work. I still get the code.
if ($mail eq'1'){
open (MAIL,"|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $email\n";
print MAIL "From: $fromsender\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Content-Type: text/html\n\n";
print MAIL $html_start, "Message: $message1", $html_end;
}
close (MAIL);
Bookmarks