use strict;use Mail:endmail;# Set up some default configurationunshift @{$Mail:endmail::mailcfg{'smtp'}} , 'necsam.com';$Mail:endmail::mailcfg{'from'} = "Corion (script) andy@necsam.com";my %mail = ( Bcc => 'andy@necsam.com', Subject => "Test 1", 'X-Mailer' => "Mail:endmail test script v0.01/$Mail:endmail::VERSION", Message => "Test number 1",);sendmail( %mail ) or die "Error: $Mail:endmail::error\n";
use Mail::Mailer;my $mailerObject = new Mail::Mailer('smtp', Server => 'mailserver.company.com');$mailerObject->open( { 'From' => 'someone@company.com', 'To' => 'someone@company.com', 'Cc' => 'someone@company.com', 'Bcc' => 'someone@company.com', 'Subject' => 'Hello World!' });print $mailerObject 'The sky is falling!';$mailerObject->close();
use Mail:endmail;# necsam.com does not appear to be an SMTP server# doing a lookup of MX records for necsam.com I found:# necsam.com. 94706 IN MX 20 mail1.nec.com.# necsam.com. 94706 IN MX 10 dns1.nec.com.# Assuming the latter is primarily for DNS - I used the formermy $server = q[mail1.nec.com];# Note: mostly use single-quotes (q[]) so that the '@' is not# interpreted. Used double-quotes (qq[]) for X-Mailer since you want# to interpret the variable $Mail:endmail::VERSIONmy %mail = ( smtp => $server, to => q[andy@necsam.com], # missing from your code bcc => q[andy@necsam.com], from => q[Corion (script) andy@necsam.com], # might cause problems subject => q[Test 1], message => q[Test number 1], 'X-Mailer' => qq[Mail:endmail test script v0.01/$Mail:endmail::VERSION],);sendmail(%mail) or die $Mail:endmail::error;print "OK. Log says:\n", $Mail:endmail::log;exit 0;
use Mail:endmail;# necsam.com does not appear to be an SMTP server# doing a lookup of MX records for necsam.com I found:# necsam.com. 94706 IN MX 20 mail1.nec.com.# necsam.com. 94706 IN MX 10 dns1.nec.com.# Assuming the latter is primarily for DNS - I used the formermy $server = q[132.24.22.19];# Note: mostly use single-quotes (q[]) so that the '@' is not# interpreted. Used double-quotes (qq[]) for X-Mailer since you want# to interpret the variable $Mail:endmail::VERSIONmy %mail = ( smtp => $server, to => q[andy@necsam.com], # missing from your code bcc => q[andy@necsam.com], from => q[andy@necsam.com], # might cause problems subject => q[Test 1], message => q[Test number 1], 'X-Mailer' => qq[Mail:endmail test script v0.01/$Mail:endmail::VERSION],# i didn't understand this X-Mailer concept);sendmail(%mail) or die $Mail:endmail::error;print "OK. Log says:\n", $Mail:endmail::log;exit 0;
I always use Mail::Mailer... use Mail::Mailer;my $mailerObject = new Mail::Mailer('smtp', Server => 'mailserver.company.com');$mailerObject->open( { 'From' => 'someone@company.com', 'To' => 'someone@company.com', 'Cc' => 'someone@company.com', 'Bcc' => 'someone@company.com', 'Subject' => 'Hello World!' });print $mailerObject 'The sky is falling!';$mailerObject->close();~Jeff
i did this, but i did ran this file as part of the performFileUpload script. And it didn't work for meHere is the snippet ... previously posted code ...sendmail(%mail) or die $Mail:endmail::error;print "OK. Log says:\n", $Mail:endmail::log;
... previously posted code ...sendmail(%mail) or die $Mail:endmail::error;print "OK. Log says:\n", $Mail:endmail::log;
use CGI::Carp qw(fatalsToBrowser);
use File::Temp qw(tempfile);my($fh, $fname) = tempfile();print $fh "OK. Log says:\n", $Mail:endmail::log;close($fh);
print "Content-type: text/html\n\n";print "OK. Log says:\n", $Mail:endmail::log;
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;my $mailerObject = new Mail::Mailer('smtp', Server => 'mailserver');$mailerObject->open({ 'From' => 'name@necusa.com', 'To' => 'name@necusa.com', 'Cc' => 'name@necusa.com', 'Bcc' => 'name@necusa.com', 'Subject' => 'Hello World!'});print $mailerObject 'The sky is falling!';$mailerObject->close();
I have run the script exclusively as an *ipl file and it doesn't send out mail.This is error from the mailserver logsMay 11 13:28:37 gemini sendmail[18836]: [ID 801593 mail.notice] k4BISXU9018836: ruleset=check_mail, arg1=, relay=[132.24.20.148], reject=553 5.1.8 ... Domain of sender address postmaster@dlint24.necsam.com does not exist...It is taking postmaster@dlint24.necsam.com as to and from addressed by default. I ran this code from the command line. Doesn't throw any error. Never sends a mail either.Thanks in advance
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;eval{my $mailerObject = new Mail::Mailer('smtp', Server => 'mailserver');$mailerObject->open({ 'From' => 'name@necusa.com', 'To' => 'name@necusa.com', 'Cc' => 'name@necusa.com', 'Bcc' => 'name@necusa.com', 'Subject' => 'Hello World!'});print $mailerObject 'The sky is falling!';$mailerObject->close();}
use strict;use TeamSite::Config;use TeamSite::IW_cfg;use MIME::Lite;my $cfg = TeamSite::IW_cfg->new();$cfg->read();my $smtp = $cfg->lookup('iwsend_mail', 'mailserver', 'smtp_mailserver');send_mail($smtp, 'hi', 'a@b.com,c@d.com', 'hello', 'The sky is falling!');exit 0;#--- Send Individual Mail ----------------------------------------------------------sub send_mail { my ($smtp, $sender, $to, $subject, $note) = @_; # Create the mail first my $msg = MIME::Lite->new( From => "$sender", To => "$to", Subject => "$subject", Type => 'multipart/mixed', #'Mime-Version' => '1.0', ); # Attach Body $msg->attach( Type => 'text/html; charset=UTF-8', Data => "$note", ); # And Finally... MIME::Lite->send('smtp', "$smtp", Timeout=>60); $msg->send();}
Try the following. An assumption is that your iw.cfg has mailserver configured. If that's not the case, get smtp in some other manner.... use strict;use TeamSite::Config;use TeamSite::IW_cfg;use MIME::Lite;my $cfg = TeamSite::IW_cfg->new();$cfg->read();...
use strict;use TeamSite::Config;use TeamSite::IW_cfg;use MIME::Lite;my $cfg = TeamSite::IW_cfg->new();$cfg->read();...
Thank you Adam, as suggested i used eval{} but this doesnt' help either. I don't get any errors. I tried runing the file in debug mode, it didn't help me a lot.Please advise
As indicated by Nipper - your coding could use some improvement.As indicated by ISCBorisB - you (or we) are assuming that you have your mailserver identified correctly (which you did not in your original code posting as I pointed out)The time you tried it and reported messages in the mailserver log - where was that log located? On the TS server or on the actual mail server?The fact that you received those messages in the mailserver log indicates that Mail:endmail (or Mail::Mailer, or ...) Managed to successfully connect to an SMTP server / service - so you are probably not going to get any errors from eval{...} because the handoff was successful - only the delivery failed and none of these modules track deliveryYou need toVerify your mailserver is defined correctlyWork with your local Mail Admin (IT, Ops, Sys Admin, Net Admin, whatever) to figure out what's happening on the SMTP server side of thingsI still think you're connecting to the wrong server -or- not configuring the From or Sender information correctly - you may need to add the following code before the mailer->open call:Code:$ENV{MAILADDRESS} = $ENV{USER} || $ENV{LOGNAME} || desired-from-address;__________________--fishSenior Consultant, Quotient Inc.http://www.quotient-inc.com
I have checked with the mail server. The server specified is correct.The log which i have posted are not on the TS server, they are from the mail server. The logs were with the Mail::Mailer module , this as you said is a clear indication that it is recognizing the mail server. But an effort to collect the From and to fields is not occuring correctly. Since it always send it to postmaster@localmachine.domain.comAs i said using eval too did not solve the issue, i don't see any error. Is there a very simple module which mandates a mail push to a To address?Thank you
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;my $mailerObject = new Mail::Mailer 'smtp', Server => 'mymailserver';$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!'}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close();
$ENV{MAILADDRESS} = $ENV{USER} || $ENV{LOGNAME} || desired-from-address;
True, even though i am specifying the right FROM address , it is always going back to postmaster@...... Thats why i wanted to try so thing like this, but alas this doesn't throw any error either. #!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;my $mailerObject = new Mail::Mailer 'smtp', Server => 'mymailserver';$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!'}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close(); Can we run a Mail::Mailer from a command line with To address as an argument?Thank you
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;my $mailerObject = new Mail::Mailer 'smtp', Server => 'mymailserver';$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!', From => 'andy@necsam.com'}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close();
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;$ENV{'andy@necsam.com'} = $ENV{doughta} || $ENV{doughta} || 'andy@necsam.com';my $mailerObject = new Mail::Mailer 'smtp', Server => 'mailserver';$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!', From => 'andy@necsam.com'}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close();
I have tried with ENV and also with From address, no luck yet.Thanks #!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;$ENV{MAILADDRESS} = $ENV{USER} || $ENV{LOGNAME} || 'andy@necsam.com';my $mailerObject = new Mail::Mailer 'smtp', Server => 'mailserver', Debug => 1;$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!', From => 'andy@necsam.com', Sender =>'TestingForAndy@necsam.com',}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close();
#!c:\Interwoven\TeamSite/iw-perl/bin/iwperl.exeuse Mail::Mailer;$ENV{MAILADDRESS} = $ENV{USER} || $ENV{LOGNAME} || 'andy@necsam.com';my $mailerObject = new Mail::Mailer 'smtp', Server => 'mailserver', Debug => 1;$mailerObject->open({ To => 'andy@necsam.com', Subject => 'Hello World!', From => 'andy@necsam.com', Sender =>'TestingForAndy@necsam.com',}) || die "could Not Open";print $mailerObject 'The sky is falling!';$mailerObject->close();
Also - just to make sure we're on the same page here - where you have: Server => 'mailserver' - can we assume that your actual code uses the actual mailserver's hostname or IP address?