Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Sending a large mail with Mail::sendMail

by mrguy123 (Hermit)
on May 20, 2007 at 09:18 UTC ( [id://616410]=perlquestion: print w/replies, xml ) Need Help??

mrguy123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks
I am writting a program that sends a mail when it is done, with a list of failed resources as output (part of a metasearch engine)
For this I am using the module Mail::SendMail
This the code
#!/exlibris/metalib/m4_b/product/bin/perl BEGIN { unshift (@INC, $ENV{'alephm_source'}.'/com_perl'); } use Mail::Sendmail; my $email ='guy.naamati@exlibris.co.il'; my $from ='guy.naamati@exlibris.co.il'; my $subject='test email'; my $message=''; my $file = ""; my $message = 'institution Name: METALIB No. of tested resources: 52 No. of failed searches (0 results or errors in all attempts): 49 Display names of these resources + Resource ID: ARTstor (CKB02692) Internet Securities, Inc. - Emerging Market Information service - EMIS + - TEMPLATE (CKB02693) IU ViewsWire (ProQuest) (CKB02673) ProQuest Snapshot Series (ProQuest) (CKB02678) Hoover's Company Records (ProQuest) (CKB02688) OxResearch (ProQuest) (CKB02687) ProQuest Newspapers Template (ProQuest) (CKB02677) American Periodicals Series - APS Online (ProQuest) (CKB02593) ProQuest Dissertations and Theses (ProQuest) (CKB02569) MDConsult (CKB03084) Canadian Newsstand Core (ProQuest) (CKB02690) ABI/INFORM Complete (ProQuest) (CKB02686) ABI/INFORM Dateline (ProQuest) (CKB02685) ABI/INFORM Trade & Industry (ProQuest) (CKB02674) PsycArticles (ProQuest) (CKB02661) Academic Research Library (ProQuest) (CKB03332) CBCA Education (ProQuest) (CKB03331) CINAHL (ProQuest) (CKB03300) ProQuest Social Science Journals (ProQuest) (CKB03288) ProQuest Science Journals (ProQuest) (CKB03287) ProQuest Humanities (ProQuest) (CKB03286) ProQuest Health & Medical Complete (ProQuest) (CKB03285) ProQuest Children's Interest (ProQuest) (CKB03284) ProQuest ANZ Newsstand (ProQuest) (CKB03283) ProQuest Law (ProQuest) (CKB03282) Canadian Business & Current Affairs - CBCA - Complete (ProQuest) (CKB0 +2602) Ethnic NewsWatch and ENW: A History (ProQuest) (CKB02601) Ethnic NewsWatch (ProQuest) (CKB02600) GenderWatch (ProQuest) (CKB02599) Alt-Press Watch (ProQuest) (CKB02598) Wilson Education Abstracts (ProQuest) (CKB02597) ProQuest Education Journals (ProQuest) (CKB02596) Criminal Justice Periodicals (ProQuest) (CKB02595) ProQuest Nursing Journals (ProQuest) (CKB02594) Research Library (ProQuest) (CKB02592) Career and Technical Education (ProQuest) (CKB02591) ProQuest Religion (ProQuest) (CKB02590) ProQuest Telecommunications (ProQuest) (CKB02589) ProQuest Computing (ProQuest) (CKB02588) ProQuest Historical Newspapers Complete (ProQuest) (CKB02587) ProQuest European Business (ProQuest) (CKB02586) To view the full results please click on the following link: http://i +l-mldev03.corp.exlibrisgroup.com:8302/tmp/test_robot_2007052011214.xl +s'; my %mail=( To => $email, From => $from, File => $file, Subject => $subject, Message => $message ); my $return = Mail::Sendmail::sendmail(%mail); $error = $Mail::Sendmail::error; $log = $Mail::Sendmail::log; #print "return=$return\n"; #print "error =$error\n"; print "log=$log\n";
This works great for short messages, but when the message is long (as in the example), the mail isn't sent. I looked at the log and the error message returned, but couldn't find anything. I also tried to send the long mail in Net::SMTP but with no success.
If I delete most of the message, the mail is sent. Does anyone know what the problem with the large message is?
Much obliged
Guy Naamati (mrguy123)

Replies are listed 'Best First'.
Re: Sending a large mail with Mail::sendMail
by jettero (Monsignor) on May 20, 2007 at 11:41 UTC

    I also tried to send the long mail in Net::SMTP but with no success.

    I don't know that other module at all, but if you used Net::SMTP, then you should know precisely why it didn't work!!

    my $smtp = Net::SMTP->new($server, Hello=>"dude!", Timeout=>20, Debug= +>1) or die; # Debug makes Net::SMTP spew the session to your STDERR.

    If you need assistance with the output, I can help, but it should be pretty clear what's going wrong.

    -Paul

      thanks for the advice
      I did have the debug mode on, but with didn't find any usefull info. I will try sending the mail to a different acount (like the other guys suggested), and if that doesn't work, I will try looking at the log again
      Thanks again Guy

        ...debug mode on, but with didn't find any usefull info...

        I find that rather hard to believe. Either there was actually useful info there or the mail system accepted the message for delivery. If it was accepted, then you need to ask your mail systems administrator why the system is silently discarding those messages ... and no amount of perl magic will save you from that fate.

        -Paul

Re: Sending a large mail with Mail::sendMail
by shigetsu (Hermit) on May 20, 2007 at 09:50 UTC

    You could be using a here-doc to 'wrap' a multiline text in a single string, i.e.

    my $message = <<'EOT'; institution Name: METALIB [...] EOT
    Use <<"EOT" if you wish for variables to be interpolated. EOT can surely be named otherwise, as long as it is consistent (as in, start of here-doc (<<'EOT') & end of here-doc (EOT) share both the same 'identifier' and the ending identifier is placed on a single, ending line).

    Have you verified the string didn't get accidentally truncated before handing it over to sendmail()?

    If it didn't, would you care to paste the output of $Mail::Sendmail::error and $Mail::Sendmail::log?

      This is the log:
      log=Mail::Sendmail v. 0.78 - Sun May 20 13:40:53 2007 Date: Sun, 20 May 2007 13:40 +0300 Server: localhost Port: 25 From: guy.naamati@exlibris.co.il Subject: test email To: guy.naamati@exlibris.co.il

        The log looks okay to me.

        There is the possibility that Sendmail is rejecting your mail due to a too large message body in size. You might want to check whether 'root' did receive some according bounces (see /var/mail/root, /var/spool/mail/root, etc.).

        Can you verify that?

      Hi there,
      this solution doesn't seem to work
      thanks, anyway

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://616410]
Approved by shigetsu
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (None)
    As of 2024-04-25 00:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found