Re: Sending Mail trough Perl using ActivePerl on windows
by GrandFather (Saint) on Jun 19, 2007 at 22:45 UTC
|
use strict;
use warnings;
use MIME::Lite;
# Configure smtp server - required one time only
MIME::Lite->send ("smtp", "smtp.server.com");
my $msg = MIME::Lite->new
(
From => 'wibble@wobble.com',
To => 'foo@boo.com',
Data => "A simple test message\n",
Subject => "Hello World",
);
$msg->send ();
DWIM is Perl's answer to Gödel
| [reply] [d/l] |
|
| [reply] |
Re: Sending Mail trough Perl using ActivePerl on windows
by NetWallah (Canon) on Jun 20, 2007 at 03:33 UTC
|
You have single quotes around the host name in your line:
$smtp = Net::SMTP->new('$my_host');
This prevents interpolation. Either use double quotes, or get rid of the quotes.
Error-checking the result will also help debugging.
"An undefined problem has an infinite number of solutions." - Robert A. Humphrey
"If you're not part of the solution, you're part of the precipitate." - Henry J. Tillman
| [reply] [d/l] |
Re: Sending Mail trough Perl using ActivePerl on windows
by shigetsu (Hermit) on Jun 19, 2007 at 22:22 UTC
|
I'm inclined to think that Net::SMTP is perhaps a bit overkill here for what you're trying to achieve (I haven't studied the according documentation extensively and don't know your exact intentions, so I may be wrong -- from what I understand, it lets you interface the SMTP server directly as if you would telnet to it on the port the SMTP service is listening to and set off your commands (that doesn't necessarily imply that the entire SMTP subset of understood commands is implemented in Net::SMTP)).
You may have a look at Mail::Sendmail, which is in my opinion much more user-friendly, but also a bit more limited (perhaps sufficient for your needs).
As it seems you're worrying about not installing extra packages (or are not permitted to do so), you could 'simply' use lib in combination with Mail::Sendmail.
Update: mention of lib
| [reply] |
|
Thanks for the hint of using lib, it's really helpfull! You are right, I can't install any module, for now. Someday I'll find out a way to do so!
| [reply] |
Re: Sending Mail trough Perl using ActivePerl on windows
by sago (Scribe) on Jun 20, 2007 at 06:43 UTC
|
Please to see the below two programs to send mail through perl using activeperl on windows.
One is using the module Mail::Sendmail and the other is using the module MIME::Lite.
Program 1 using the module Mail::Sendmail.
#!C:/Perl/bin/perl.exe
use Mail::Sendmail;
my $to_list = 'john@gmail.com';
my $cc_list = 'frank@yahoo.com';
my $email = "\n\nThis email was generated automatically.\n";
my $MailFrom = "test\@gmail.com";
my $subject = "hello test";
my $message = "module test";
%mail = (
To => $to_list,
From => $MailFrom,
Bcc => $bcc_list,
Cc => $cc_list,
Subject => $subject,
Message => $message
);
$mail{Smtp} = 'mailtest.gmail.com';
sendmail(%mail)
Program 2 using the module MIME.
#!C:/Perl/bin/perl.exe
use MIME::Lite;
MIME::Lite->send('smtp', "mailtesthub.gmail.com", Timeout=>90);
my $email = "This email was generated automatically.";
my $subject = "hello test";
my $MailFrom = "john@gmail.com";
my $to_list = 'frank@yahoo.com';
my $cc_list = 'sam@rediffmail.com';
$msg = MIME::Lite->new(
From => $MailFrom,
To => $to_list,
Cc => $cc_list,
Bcc => $bcc_list,
Subject => $subject,
Type => 'TEXT',
Encoding=> '7bit',
Data => $a
);
$msg->send()
| [reply] |
|
Thanks a lot!with the use of lib and Mail::Sendmail, I've finaly be able to send my email alerts, and moreover, I find out to be able to send an .xls file attached to it.
Thanks to all of you who helped me!
| [reply] |
|
Hi,
I am using activeperl and tried to send mail using the Mail::sendmail code provided by you. I am not getting errors when i run the perl script but my also doesn't go.
here is my script. How do I provide login information to the gmail server, or is it not required? Is this the right way?
#!C:/Perl/bin/perl.exe
use Mail::Sendmail;
print "Hello World1.\n";
my $to_list = 'gsarin83@gmail.com';
my $cc_list = 'aryan_42k@yahoo.com';
my $email = "\n\nThis email was generated automatically.\n";
my $MailFrom = "gs.engr@gmail.com";
my $subject = "hello test";
print "Hello World2.\n";
my $message = "module test";
%mail = (
To => $to_list,
From => $MailFrom,
Bcc => $bcc_list,
Cc => $cc_list,
Subject => $subject,
Message => $message
);
$mail{Smtp} = 'smtp.gmail.com';
sendmail(%mail);
print "Hello World3.\n";
Thanks,
Gaurav
| [reply] |
|
Hi
I am also wroking on same task( Sending email when ever there is error in logs) to know how to lib please can u share your perl program. by refering your program i can complete my task.
don't have Mail::Mailer & Mail::Sendmail; installed.
| [reply] |
|
Hi,
I am using activeperl and tried to send mail using the Mail::sendmail code provided by you. I am not getting errors when i run the perl script but my also doesn't go.
here is my script. How do I provide login information to the gmail server, or is it not required? Is this the right way?
| [reply] |
|
#!C:/Perl/bin/perl.exe
use warnings;
use Mail::Sendmail;
my $to_list = 'someone@gmail.com';
my $email = "\n\nThis email was generated automatically.\n";
my $MailFrom = 'dipeshkumar.dutta@gmail.com';
my $subject = "hello test";
my $message = "module test";
%mail = (
To => $to_list,
From => $MailFrom,
Subject => $subject,
Message => $message
);
$mail{Smtp} = 'smtp.gmail.com';
sendmail(%mail)or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
I am using the above script but facing the following error.
MAIL FROM: error (530 5.7.0 Must issue a STARTTLS command first. 5sm12
+048018qwg.10)
Can any body help me to fis this error.
Thanks in Advance!
| [reply] [d/l] [select] |
|
| [reply] |
Re: Sending Mail trough Perl using ActivePerl on windows
by camenix (Acolyte) on May 02, 2010 at 00:16 UTC
|
It may be too late for this question,but the below link shows a sample about how to send an email by NET::SMTP.
http://www.perlmonks.org/?node_id=837884
In Window32,there is no native command email client to be used,POP3 of Windows2003 may be the only tool.If you have installed IIS or Outlook(Outlook express is limited) ,Try WIn32::OLE to send a mail.
| [reply] |
Re: Sending Mail trough Perl using ActivePerl on windows
by Anonymous Monk on Oct 06, 2015 at 10:29 UTC
|
#!/usr/bin/perl
use MIME::Lite;
$to = 'abcd@gmail.com';
$cc = 'efgh@mail.com';
$from = 'webmaster@yourdomain.com';
$subject = 'Test Email';
$message = 'This is test email sent by Perl Script';
$msg = MIME::Lite->new(
From => $from,
To => $to,
Cc => $cc,
Subject => $subject,
Type => 'multipart/mixed'
);
# Add your text message.
$msg->attach(Type => 'text',
Data => $message
);
# Specify your file as attachement.
$msg->attach(Type => 'image/gif',
Path => '/tmp/logo.gif',
Filename => 'logo.gif',
Disposition => 'attachment'
);
$msg->send;
print "Email Sent Successfully\n";
| [reply] [d/l] |
|
Hey All,
This code dates from 2015. MIME::Lite is not shipped with ActiveState's perl any more, and trying to install it (I used "cpan MIME::Lite") fails with a host of errors. I had similar problems with Mail::Sendmail.
Does anyone have a solution that works in 2020? I'm using ActiveState 5.28.1.
Thanks in advance,
Lars
| [reply] |
|
| [reply] |
|
|
|
|