I have a script that sends a spreadsheet to a list of recipients. If I run it from the command line it works just fine. If I run it as a cronjob I get

"FROM: userx@linux.server.com does not end with localhost.localdomain".

I've turned on debugging and I get:

>> 220 int2.disney.pvt ESMTP Sendmail Sentrion-MTA-4.2.2/Sentrion-MTA- +4.2.2; Fri, 21 Jun 2013 12:17:14 GMT << EHLO localhost.localdomain >> 250-int2.disney.pvt Hello linu.server.com [172.27.75.45], pleased t +o meet you >> 250-ENHANCEDSTATUSCODES >> 250-PIPELINING >> 250-8BITMIME >> 250-SIZE 26214400 >> 250-DSN >> 250-ETRN >> 250-STARTTLS >> 250-DELIVERBY >> 250 HELP << MAIL FROM:<userx@xyz..com> >> 550 5.7.1 <userx@xyz.com>... Relaying denied. MAIL FROM: userx.@xy +z.disney.com does not end with localhost.localdomain << quit

The script

#!/usr/bin/perl -w use strict; use Mail::Sender; # need to set PATH for cron? $ENV{'PATH'} = '/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/sb +in:/sbin'; # Get latest KPI spreadsheet my $send_file = 'file_to_send.xls' open my $DEBUG, ">> /tmp/j1.txt" or die "Fail $!\n"; # Set up mail sender my $sender = new Mail::Sender ( { smtp => 'a.relay.server.com', from => 'userx@.xyz.com', debug => $DEBUG, debug_level => 4, }); if ($Mail::Sender::Error) { print "New failed: $Mail::Sender::Error\n"; exit (); } # variables for email # Glenn.Lochen@xerox.com #my $To = q(jesse.carroll@xerox.com, Craig.Elliott@xerox.com); my $To = q(userz.@xyz.com); my $subject = q(A Spreadsheet); my $msg = q(Today's spreadsheet is attached); # send the file $sender->MailFile( { to => $To, subject => $subject, msg => $msg, file => $current_spreadsheet, }); if ($Mail::Sender::Error) { print "Send failed: $Mail::Sender::Error\n"; exit (); } else { print "$current_spreadsheet sent to $To\n"; }

Of course I've change some names. Any help would be greatly appreciated


In reply to Mail::Sender MAIL FROM: does not end with localhost.localdomain by essej1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.