perlquestion
ted.byers
<p>Hi All</p>
<p>I have a particularly obscure and puzzling problem. The following code works perfectly on my workstation (64 bit Windows 7, 64 bit Activestate perl 5.12). I am trying to set the script up on a Server running Windows Server 2003 (but the same version of Perl - in fact, I copied the whole C:\Perl64 directory tree from the above workstation to the server, which happend very quickly over a 1GB LAN, and set up the environment variables appropriately)</p>
<p>Alas, the problem is that while the script works perfectly on the workstation, it dies with the above error on the server.</p><p>I did do a search of this forum, and found information about 'use Authen::SASL qw(Perl);'. Authen::SASL is in fact installed, and adding the use statement 'use Authen::SASL qw(Perl);' at the beginning of the script changes nothing!</p><p>Here is the code:</p>
<code>use strict;
use MIME::Lite;
my $subject="A first MIME::Lite test on gmail";
my $message="A Daily PDF report is attached.Just to see if this works";
my $to = "r.ted.byers\@gmail.com";
my $file = "mysamplefile.pdf";
my $from = "\"Me\" <me\@here.com>";
print "Sending test email.\n";
make_and_send_email($from,$to,$subject,$message,$file);
print "Test email sent.\n";
sub make_and_send_email{
my ($from, $to,$subject,$message, $path) =@_;
my $un='myun';
my $pw='mypwd';
my $msg = MIME::Lite->new(
From => $from,
'Reply-to' => $from,
To => $to,
Subject => $subject,
Type =>'multipart/related'
) or die "Cannot create a new email instance!";
$msg->attach(Type => 'TEXT',
Data => $message,
) or die "Error adding TXT: $!\n";
$msg->attach(Type => 'aplication/pdf',
Path => $path,
Disposition => 'attachment'
) or die "Error adding PDF: $!\n";
MIME::Lite->send('smtp','smtp.gmail.com',AuthUser=>$un, AuthPass=>$pw, Timeout => 60);
$msg->send();
return 0;
}
</code>
<p>Here is the output on the workstation:</p>
<pre>
C:/Perl64/bin\perl.exe -w c:/Work/gmail.test.pl
Sending test email.
Test email sent.
Compilation finished at Tue Sep 13 11:33:59
</pre>
<p>and here is the output on the server:</p>
<pre>
C:/Perl64/bin\perl.exe -w c:/Work/gmail.test.pl
Sending test email.
SMTP auth() command not supported on smtp.gmail.com
Compilation exited abnormally with code 255 at Tue Sep 13 16:47:12
</pre>
<p> Since I copied everything in C:\Perl64 on the workstation to the same location on the server (and set PERL_HOME to C:\Perl64 as an environment variable), what could possibly be different between the two machines that would account for the different outcomes? Of course, I used the same credentials on both machines.</p><p>This is the first time I have shifted code from one machine to another only to find it breaking (and in fact I do this alot).</p><p>Any guidance on how to fix this would be appreciated.</p><p>Thanks</p><p>Ted</p>