Hello:
I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp.
For some reason instead of receiving the email with the HTML showing a link that will open up my PopUp... Im getting all the HTML tags and javasacript code printed on my email.
What am I doing wrong..??
Here is the code:
The following code is the subroutine that handles the email sending
If you know of a better approach to accomplish the same thing I would appreciat it
Thanx
VirtualWeb
I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp.
For some reason instead of receiving the email with the HTML showing a link that will open up my PopUp... Im getting all the HTML tags and javasacript code printed on my email.
What am I doing wrong..??
Here is the code:
Code:
$To_Email = '123@yahoo.com';
$From_Email = 'info@myemail.com';
$Email_Subject = 'TEST SEND ATTACHMENT (3)';
$Email_Body = 'Here u can put whatever text msg meeds to be sent in the mail!!!';
$html_attachment_text = "<html>\n";
$html_attachment_text .= "<body bgcolor=gray><script>\n";
$html_attachment_text .= "function Loging_Pop_Up() {\n";
$html_attachment_text .= "var w = window.open(\"Loging_Form.pl?URL=$URL\",\"smallwin\",\"width=800,height=600,status=no,resizeable=yes, scrollbars=yes\");{\n";
$html_attachment_text .= "}\n ";
$html_attachment_text .= "</script>\n";
$html_attachment_text .= "<b><font color=red>This is test line1</font><br><br>\n";
$html_attachment_text .= "<font color=white>This is where you can put your html template, i.e. whatever will be in string html_attachment_text will be sent as html attrachment with the mail.<br></font>\n ";
$html_attachment_text .= "<A HREF=\"http://www.altavista.com\" onClick=\"Loging_Pop_Up(); return false;\">[Link to Altavista]</A>\n";
$html_attachment_text .= "</body>\n";
$html_attachment_text .= "</html>\n";
&sendemail($User_Email, $Admin_Email, "$Email_Subject", "$Email_Body", "$html_attachment_text");
Code:
sub sendemail {
$Mail_Program = '/usr/sbin/sendmail -t';
my ($to,$from,$subject,$message,$attachment) = @_;
my $boundary = "xxxxx".time()."xxxxx";
open MAIL, "|$Mail_Program";
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: multipart/mixed;";
print MAIL " boundary=\"$boundary\"\n";
print MAIL "Subject: $subject\n\n";
print MAIL "--$boundary\n";
print MAIL "Content-Type: text/plain; charset=utf-8\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
print MAIL "$message\n";
print MAIL "--$boundary\n";
print MAIL "Content-Type: text/html; charset=utf-8\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
print MAIL "$attachment";
print MAIL "--$boundary--";
close MAIL;
}
Thanx
VirtualWeb
Comment