Sending PopUp code on the body of an email from a script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • virtualweb
    New Member
    • Aug 2007
    • 30

    Sending PopUp code on the body of an email from a script

    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:

    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");
    The following code is the subroutine that handles the email sending
    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;        
    }
    If you know of a better approach to accomplish the same thing I would appreciat it

    Thanx
    VirtualWeb
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    The email will have to have the proper headers, currently you are using both text/html and text/plain. Try removing the text/plain portion of the header sent.

    Your code looks like it could be reduced. If I get time later I will look at your code again.

    --Kevin

    Comment

    • virtualweb
      New Member
      • Aug 2007
      • 30

      #3
      Kevin:
      Your suggestion worked.. thank you


      VirtualWeb

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        You're welcome.

        Regards,
        Kevin

        :)

        Comment

        Working...