View Single Post
  #5 (permalink)  
Old 06-19-07, 08:03 AM
sujata_ghosh sujata_ghosh is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot!

yes i am getting email but as i have not added anything to display on the screen so i was getting error message. now it's working. now i need to know some more info,


1) the email script i was using which take data from diffent variable as follows:

perl Code:
  1. sub send_mail{
  2.  
  3.  my @boundaryv = (0..9, 'A'..'F');
  4.  $PREF{'FOOTER'} =~ s/\\n/\n/g;
  5.  $| = 1;
  6.  srand(time ^ $$);
  7.  my @boundaryv = (0..9, 'A'..'F');
  8.  for (my $i = 0; $i++ < 24;)
  9.  {
  10.   $boundary .= $boundaryv&#91;rand(@boundaryv)];
  11.  }
  12.  
  13.       #foreach my $file (@files)
  14.        #{
  15.           do { push @problem, "$file"; next; } if !-r "$upload_dir/$file"; # checks the existence and readability
  16.           my ($boundary, $ext) = (undef, undef);
  17.           #--------------------------------------------------- Obtain content-type of file
  18.    ($ext) = $file =~ m,\.(&#91;^\.]*)$,;
  19.     $ext =~ tr,a-z,A-Z,;
  20.            my $fext = $mime{$ext};
  21.           #--------------------------------------------------- Generate multipart boundary
  22.      srand(time ^ $$);
  23.      for (my $i = 0; $i++ < 24;)
  24.       {
  25.              $boundary .= $boundaryv&#91;rand(@boundaryv)];
  26.       }
  27.           #--------------------------------------------------- Send attatchments etc...
  28.  
  29. open MAIL, "| $mail_prog -finrreturn\@k****ij.com" || die "I was not able to open the mail program<BR>contact the server's technical administrator.<BR><BR>If this is not admin, please let him/her<BR> know about this problem.";
  30. print MAIL "To: $em\n";
  31. print MAIL "From: Vikram Murarka <vikram\@k****ij.com>\n";
  32. print MAIL "Return-Path: Vikram Murarka <vikram\@k****ij.com>\n";
  33. print MAIL "Reply-To: Vikram Murarka <vikram\@k****ij.com>\n";
  34. print MAIL "X-Mailer: Custom-CGI: Web Mailer v1.02\n";
  35. print MAIL "MIME-Version: 1.0\n";
  36. print MAIL "Subject: $INPUT{'subject'}\n";
  37. print MAIL "Content-Type: multipart/mixed; boundary=\"------------$boundary\"\n";
  38. print MAIL "\n";
  39. print MAIL "This is a multi-part message in MIME format.\n";
  40. print MAIL "--------------$boundary\n";
  41. print MAIL "Content-Type: text/plain; charset=us-ascii\n";
  42. print MAIL "Content-Transfer-Encoding: 7bit\n\n";
  43.            
  44. print MAIL "$subject \n";
  45. if (!$edition)
  46. {
  47. $edition = "";
  48. print MAIL "$edition";
  49. }
  50. else
  51. {
  52. print MAIL "$edition \n";
  53. }
  54. print MAIL "$time \n\n";
  55.  
  56. if ((!$inr1) && (!$inrm1))
  57. {
  58. $inr1 = "";
  59. $inrm1 = "";
  60. print MAIL "$inr1";
  61. print MAIL "$inrm1";
  62. }
  63. else
  64. {
  65. print MAIL "$inr1\n";
  66. print MAIL "$inrm1\n\n";
  67. }
  68. if ((!$fwd1) && (!$fwdm1))
  69. {
  70. $fwd1 = "";
  71. $fwd1 = "";
  72. print MAIL "$fwd1";
  73. print MAIL "$fwdm1";
  74. }
  75. else
  76. {
  77. print MAIL "$fwd1\n";
  78. print MAIL "$fwdm1\n\n\n";
  79. }
  80. if ((!$strategy1) && (!$strategym1))
  81. {
  82. $strategy1 = "";
  83. $strategym1 = "";
  84. print MAIL "$strategy1";
  85. print MAIL "$strategym1";
  86. }
  87. else
  88. {
  89. print MAIL "$strategy1\n";
  90. print MAIL "$strategym1\n\n";
  91. }
  92. if ((!$eurrs1) && (!$eurrsm1))
  93. {
  94. $eurrs1 = "";
  95. $eurrsm1 = "";
  96. print MAIL "$eurrs1";
  97. print MAIL "$eurrsm1";
  98. }
  99. else
  100. {
  101. print MAIL "$eurrsmail2\n\n";
  102. print MAIL "$eurrsmmail2\n\n\n";
  103. }
  104.  
  105. print MAIL "$dis\n\n";
  106.             print MAIL "\n";
  107.    close MAIL;
  108. }
  109.  
  110.  sub encode_base64 #($)
  111.    {
  112.       my ($res, $eol, $padding) = ("", "\n", undef);
  113.       while (($_&#91;0] =~ /(.{1,45})/gs))
  114.        {
  115.     $res .= substr(pack('u', $1), 1);
  116.     chop $res;
  117.        }
  118.       $res =~ tr#` -_#AA-Za-z0-9+/#;                 # ` help emacs
  119.       $padding = (3 - length($_&#91;0]) % 3) % 3;     # fix padding at the end
  120.       $res =~ s#.{$padding}$#'=' x $padding#e if $padding;    # pad eoedv data with ='s
  121.       $res =~ s#(.{1,76})#$1$eol#g if (length $eol);          # lines of at least 76 characters
  122.       return $res;
  123.    }


now how i will converted into it:

perl Code:
  1. #!/usr/bin/perl -w
  2. use MIME::Lite;
  3. my $message_body = "Here's the attachment file(s) you wanted<br><b>h</b>";
  4.     ### Create a new single-part message, to send a GIF file:
  5.     $msg = MIME::Lite->new(
  6.         From     =>'sujata@k****ij.com',
  7.         To       =>'sujata_atkcs@yahoo.com',
  8.         Cc       =>'sujata_ghosh@hotmail.com, [EMAIL="sujata_ghosh1@rediffmail.com'"]sujata_ghosh1@rediffmail.com'[/EMAIL],
  9.         Subject  =>'Helloooooo, nurse!',
  10.         Type     =>'application/octet-stream',
  11.         Encoding =>'base64',
  12.         Path     =>'/home/k****ijc/www/temp/inr rates.xls'
  13.     );
  14. $msg->attach (
  15.   Type => 'text/html',
  16.   Data => $message_body
  17. ) or die "Error adding the text message part: $!\n";
  18.     $msg->send; # send via default
  19. print "Content-type: text/html\n\n";
  20. print "Message sent";

2) i am using a script which take data from form and make HTML page and send HTML mail using same email script and additional code only i change the 'text/html' part this email message consist of images which appears with email body message, but it is not showing into email. as we are using this code to display it on HTMl page: (<img src="full path of the file">) how i will use the same to display it on proper place in the email body with text?

Thanks once again.

Last edited by UnrealEd; 06-19-07 at 08:22 AM. Reason: please use the correct syntax highlighters!!
Reply With Quote