in reply to Email program with attachments

Hi blacksmith

This code works for me:
my $sender = new Mail::Sender( {from => $work, smtp => 'mail.domain. +com'}) || die "$Mail::Sender::Error\n"; (ref $sender->MailFile({to => $email, subject => $subj_line, file => \@files, encoding => 'base64', msg => 'Here are the price change worksheets +.'}) ) || die "Error on $email: $Mail::Sender::Error\n";
Also, what version of Mail::Sender are you using? The latest version is 0.7.08.

Simon Flack ($code or die)
$,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
=~y'_"' ';eval"die";print $_,lc substr$@,0,3;

Replies are listed 'Best First'.
Re: Re: Email program with attachments
by blacksmith (Hermit) on Oct 09, 2001 at 23:02 UTC
    Thanks $code or die. The readme file says version 0.7.09. The code you provided works great. My knowledge of the ref command is lacking. But, I am still having a problem with email addresses outside of the SMTP server. I am recieving this error message
    Error on myaccount@yahoo.com: Local user "myaccount@yahoo.com" unknown on host "mail.domain.com"
    I have also tried accounts other than yahoo. If I put the addresses into a hash such as so
    #!Perl -w use strict; use Mail::Sender; my $time = localtime; my $subj_line = "Price Change Worksheet for $time"; my %file = ('employee@theirjob.com'=>'P:\\PCW1.TXT','storeowner@aol.co +m'=>'P:\\PCW2.TXT'); my $work = 'me@work.com'; foreach (keys %file) { my $sender = new Mail::Sender( {smtp => 'mail.domain.com',from => $wor +k}) || die "$Mail::Sender::Error\n"; $sender->OpenMultipart( {to => $_, subject => $subj_line}); $sender->Body; $sender->SendLine('Here are the price change worksheets.'); $sender->SendFile( {description => 'Text File', encoding => 'Base64', file => $file{$_}}) and print "Mail was sent OK." || die "$Mail::Sender::Error\n"; $sender->Close; }
    I have no problem sending mail outside of the company's mail server. WAIT!! WAIT!! I just tested that program again. It did NOT work. It gave me the error messages that I was receiving from the origin message of this thread. Okay, here is the kicker. It worked previously. The recipient of one of the mails even replied to it. Spoke with one of the Admins and was told that there is nothing wrong with the mail server. I am able to send out messages manually. Any ideas on what could be going on? Thanks again.
    blacksmith
      I would say, double-check what you have on these lines:
      my $work = 'me@work.com';
      and
      ... new Mail::Sender( {smtp => 'mail.domain.com',from => $work}) ...
      I think you forgot to change either the mailserver name or your work address. It's very likely that your SMTP server rejects emails unless the sender or recipient is a valid local account. So if you still have me@work.com as an email address or the wrong mail server, then it will be rejected.

      Simon Flack ($code or die)
      $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
      =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
        I did that once before. Talk about feeling stupid. I verified and ran the program again. Same error. I am totally stumped. In your reply you said, "It's very likely that your SMTP server rejects emails unless the sender or recipient is a valid local account." Could it be possible that the email server rejects an address if it is not on the local network? I do not know if this could be an issue since I can send email to all the email accounts I have been testing that are outside of the network when manually opening MS Outlook and attaching the files. Thanks for the help. blacksmith.