473,416 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Mail:SendMail Troubleshooting

Hi I am new here and once upon a time I worked with Perl, now I am trying again and need some help:

I wrote a Perl script a few years ago that opened an order entry TXT file and sent each customer with an email address a confirmation email in html or txt. Simple enough and very effective.

Now I am editing this script to send a general email blast on a new computer... I have ActivePerl 5.10.0 Build 1003 installed. I downloaded Mail:Sendmail and put SendMail.pm in C:\Perl\lib\Mail

First, I have a question about Perl and Mail:SendMail installation:

I am not sure that's all I have to do to install SendMail.pm right. For example, it doesn't show up in the Perl Package Manager from ActivePerl. If I view all packages and go to Mail:SendMail and select Install it warns me: WARNING: Installing Mail-Sendmail-0.79 would downgrade Mail::Sendmail from version 2.09 to 0.79

So I assume that the new version I dropped in lib\Mail 2.09 is installed.

???? right ????

I downloaded a trial version of Komodo IDE 4.4 to do my editing and debugging. Curious, what applications do people here recommend?

I made some edits to the script that basically remove the array looking for order details. My new email blast TXT is a simple tab delimited format: name (tab) email address (eol).

I am getting an error at the SendMail line. Here are some details...

Here's the opening of the file:

Expand|Select|Wrap|Line Numbers
  1. use strict; 
  2. use Fcntl; 
  3. use Data::Dumper; 
  4. use Mail::Sendmail; 
  5. use MIME::QuotedPrint; 
  6. use MIME::Base64; 
  7. use HTML::Entities; 
Here are the errors from the debugger:
Expand|Select|Wrap|Line Numbers
  1. > Ambiguous use of % resolved as operator % at C:\BasicEmailBlaster.pl line 183. 
  2.  
  3. > Bareword "sendmail" not allowed while "strict subs" in use at C:\BasicEmailBlaster.pl line 183. 
  4.  
  5. > Bareword "mail" not allowed while "strict subs" in use at C:\BasicEmailBlaster.pl line 183. 
  6.  
  7. > Execution of C:\BasicEmailBlaster.pl aborted due to compilation errors. 
Here is the Sub leading up to the Error - Error is on line 183 - the last line below:

Expand|Select|Wrap|Line Numbers
  1. sub SendEmail 
  2. my $bResult = 1; 
  3.  
  4. print "- SENDING CONFIRMATION EMAIL" . "\n"; 
  5.  
  6. my $MAILLOG; 
  7.  
  8. print "- Attempting Open: " . '>> '. $MailLogFile ."\n"; 
  9.  
  10. if ( ! open( MAILLOG, '>> '. $MailLogFile ) ) 
  11. print "Failed to open Email Log!\n"; 
  12. print "- Attempting Open: " . '>> '. $LogFile ."\n"; 
  13.  
  14. # log error message if not able to log email 
  15. &LogIt("Can't Log Email>>\nCan't Open:\t" . $MailLogFile); 
  16. undef $MAILLOG; 
  17. else 
  18. $MAILLOG = *MAILLOG; 
  19.  
  20. if ( defined $MAILLOG ) 
  21. {    
  22. print $MAILLOG (">> Mail Entry Start\n"); 
  23.  
  24. if ( !BuildEmail( \%mail ) ) 
  25. print "Building the Email Failed!\n"; 
  26. if ( defined $MAILLOG ) 
  27. {    
  28. print $MAILLOG (localtime( time ) . "\tBuilding the Email Failed!\n"); 
  29. &LogIt("Building the Email Failed!"); 
  30. $bResult = 0; 
  31. else 
  32. print "- Attempting Sendmail!\n"; 
  33.  
  34. 183     if (sendmail %mail) 
  35.  
  36. This is defining %mail
  37.  
  38. sub BuildEmail
  39. {
  40.     print "- BUILDING CONFIRMATION EMAIL" . "\n";
  41.  
  42.     my $OrderTxt = "";
  43.     my $OrderHtm = "";
  44.     for (my $i = 0; $i < 65; $i++)    
  45.     {
  46.         $OrderTxt.= $EmailArrayTxt[$i];
  47.         $OrderHtm.= $EmailArrayHtm[$i];
  48.     }
  49.  
  50.     my ($MailHash) = shift;
  51.     my %mail = %$MailHash;
  52.     my $boundary = "====" . time() . "====";
  53.  
  54.     $MailHash->{From}    = 'Me <me@none.com>';
  55.     $MailHash->{To}      = $To;
  56.     $MailHash->{Bcc}     = 'none@none.com';
  57.     $MailHash->{smtp}    = 'mail.mail.com';
  58.     $MailHash->{subject} = "Subjects";
  59.     $MailHash->{'content-type'} = "multipart/alternative; boundary=\"$boundary\"";
  60.  
  61.     local $/;                   # slurp mode (undef)
  62.     local *F;                   # create local filehandle
  63.  
  64.     my $filename = 'C:\EmailBlasts\EmailTemplates\EmailBlast.txt';
  65.  
  66.     print "- Opening $filename\n";
  67.     if ( !open(F, "<$filename") )
  68.     {
  69.         &LogIt("Can't Open:\t" . $filename);
  70.         return 0;    
  71.     }
  72.  
  73.     my $tempText = <F>;         # read whole file
  74.     close(F);                   # ignore retval
  75.  
  76.     $tempText =~ s/%%Order%%/$OrderTxt/eg;
  77.  
  78.     my $plain = encode_qp $tempText;
  79.  
  80.     my $filename = 'C:\EmailBlasts\EmailTemplates\EmailBlast.html';
  81.  
  82.     print "- Opening $filename\n";
  83.     if ( !open(F, "<$filename") )
  84.     {
  85.         &LogIt("Can't Open:\t" . $filename);
  86.         return 0;    
  87.     }
  88.  
  89.     my $tempText = <F>;            # read whole file
  90.     close(F);                   # ignore retval
  91.  
  92.     $tempText =~ s/%%Order%%/$OrderHtm/eg;
  93.  
  94.     my $html = encode_qp $tempText;
  95.  
  96.  
  97. $MailHash->{body} = <<END_OF_BODY;
  98. --$boundary
  99. Content-Type: text/plain; charset="iso-8859-1"
  100. Content-Transfer-Encoding: quoted-printable
  101.  
  102. $plain
  103.  
  104. --$boundary
  105. Content-Type: text/html; charset="iso-8859-1"
  106. Content-Transfer-Encoding: quoted-printable
  107.  
  108. $html
  109.  
  110. --$boundary--
  111. END_OF_BODY
  112.  
  113. }
  114.  
Any Ideas
Sep 4 '08 #1
3 3354
Okay, I solved my problem by installing the Mail:SendMail 0.79 against PPMs advice. Now I need to add SMTP Authentication to my code. My new server authenticates, how do I do that?

Here's what I have now:

My settings:
Expand|Select|Wrap|Line Numbers
  1. $MailHash->{From} = '**@***.com'; 
  2. $MailHash->{To} = $To; 
  3. $MailHash->{Bcc} = '**@***.com'; 
  4. $MailHash->{smtp} = 'mail.mail.com'; 
  5. $MailHash->{subject} = "Newsletter"; 
  6. $MailHash->{'content-type'} = "multipart/alternative; boundary=\"$boundary\"";
Sep 4 '08 #2
KevinADC
4,059 Expert 2GB
As suggested on perlguru, you may need to switch to Net::SMTP. The module you are using does not appear to support authentication.
Sep 4 '08 #3
aww you're everywhere. thanks.
Sep 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: CoralineSage | last post by:
Hi All, I'm running a bulleting board in PHP and everytime a new user registers s/he is supposed to receive an email confirmation. After filling out the registration form and clicking on submit...
3
by: Andrew McLean | last post by:
I am writing a CGI script on an account that only has Python 1.5.2. It's principal purpose is to take some user input from a form, do some manipulation and return some information to the user....
1
by: murph | last post by:
Hi , I have created a little script that is running as daemon ( it is hard to say as daemon :)) ) . Then i try to send a mail and the mail is refused from sendmail. I have no idea why it...
7
by: Shelly | last post by:
I submitted this to comp.mail.sendmail, but maybe someone here can help me as well. OK, this has most likely been asked and answered several times, but I am still confused after searching. Here...
2
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
6
by: Guern1 | last post by:
Help Please I am very new to the Perl game and need some help I have a Perl application which works fine and can output some plain text information that I need to send to selected users via...
0
by: s2rinivasan | last post by:
I am srinivasan I sent a last message hoe to trouble shoot httpd passwd acces problum. In that I didn't menson that OS=RedHat LINUX EL4-2.6.9-5. This question also in the same version. In...
3
by: zaxxon25 | last post by:
I am having an issue with attaching 2 attachments one xip and other excel file with email and sending using perl sendmail. I tried to look on various forums and everywhere i get advice using MIME ::...
2
mikek12004
by: mikek12004 | last post by:
Before posting here I google it and saw ablut 30 pages for a solution so I pretty much excluded the obvious things. The code is <?php //now to send the mails to seller...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.