Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29905

Email::Stuffer cannot send plain email without file attachment

$
0
0

System: Ubuntu 18.04 LTS with Perl 5.26.1. @grinnz

Email::Stuffer is new to me, and the examples were few in the docs. I've spent a few hours trying different things and doing research on search engines and searching for topics on other forums like this one. I create my email object like this:

my $email = Email::Stuffer
        ->text_body($body)
        ->subject($subjparam)
        ->from($from)# or use ->from($email1, $email2...)
        ->transport(Email::Sender::Transport::SMTP->new({
            host => $smtpserver,
            port => $smtpport,
            username => $smtpuser,
            password => $smtppw,
        }));

Then I send it like this:

try {
    $email->send; # Send email
}
catch {
    $s="$procname ERROR: Could not send email via $module\n";
    if ($^E)
        {
        $s.="ERROR from \$^E: ".$^E."\n";
        }
    if ($@)
        {
        $s.="ERROR from Perl: ".$@."\n";
        }
    if ($!)
        {
        $s.="ERROR from c lib: ".$!."\n";
        }
    debugprg($s);
    exit 1;
};

But every time I get a run time error "file not found" error on the $email->send. I can't seem to find any other error facility within Email::Stuffer, which uses Email:MIME.

I don't see any error objects in Email::MIME either.

Anyone know why I'm getting an error? I'm not attaching a file at all.

Thank you for any help. :)

EDIT: Here's my whole test program. You will have to supply your own SMTP server info.

#!/usr/bin/perl
=pod

Put docs here.

=cut


use warnings;
use strict;
use Email::Stuffer;
use Email::Sender::Transport::SMTP ();

require '/home/chuck/perl/util2.pl';
my $VER="v1.00";
my $s='';
my $procname='';
my $prefixsp='';
my $module='Email::Stuffer';

my ($smtpserver,$smtpport,$smtpuser,$smtppw)=getconfigg(); # Get config from INI file

# Make email.
my $from='croberts@gilsongraphics.com';
my $to='croberts@gilsongraphics.com';
my $subjparam='Test email from Perl';
my @bodyarr=("This is a test email.");
my $body=join('', @bodyarr);
my $progdir='/home/chuck/perl/';
my $smtplogfn=$progdir.'logsmtp2020.txt';

# Do it raw.
my $email = Email::Stuffer
        ->to($to)
        ->text_body($body)
        ->subject($subjparam)
        ->from($from)# or use ->from($email1, $email2...)
        ->transport(Email::Sender::Transport::SMTP->new('SMTP', {
            host => $smtpserver,
            port => $smtpport,
            username => $smtpuser,
            password => $smtppw,
            }));
if ((not defined $email) ) # Check for $email creation error.
    {
    $s=$prefixsp."$procname ERROR_undef_email: Could not create new email: $_";
    debugprg($s);
    return;
    }

$email->send;
if ($@)
    {
    $s="$procname ERROR_senderror: Could not send email via $module\n";
    if ($@)
        {
        $s.="ERROR from Perl: ".$@."\n";
        }
    print "$s\n";
    exit 1;
}


exit; # Exit main pgm.

Viewing all articles
Browse latest Browse all 29905

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>