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

email::sender doesn't work when I add transport

$
0
0

I am trying to use email::Sender on a Linux RH 7.7 box where I want to include the transport information. In the old MIME::Lite version all we needed to do as set the SMTP host to mailhost and the email was set out fine, but with Email::Sender::Transport::SMTP->new() you need to also set the port number. If I don't $transport in the sendmail() call it works fine. Our SA says the port number should be 25 but when I try 25 I get "Relay access denied". There are long writes ups online of what could cause this, but I am not a SA and can't look at any of this stuff.

So how does one find the port number to use for mailhost which I understand is the linux default setting? I have tried port 25, 2525, 587 and all have failed. My SA has no idea what is going on or how to fine what is failing. All the tutorial and code examples are just doing host= $stmp or port = $port which is not really helpful.

use Email::Sender::Simple qw(sendmail);
use Email::Simple;
use Email::Simple::Creator;
use Email::Sender::Transport::SMTP qw();
use Try::Tiny;

try {
    # Create the email message
    my $email = Email::Simple->create(
        header => [
            To      => $emailNames,
            From    => 'MMSUser@ecs.nasa.gov',
            Subject => $configFile{'email'}{$type}{'subject'},
        ],
        body => $message,
    );

    my $transport = Email::Sender::Transport::SMTP->new({
        host => 'mailhost',
        port => 25,
    });

    # send the email
    sendmail($email, { transport => $transport });
    } catch {
    my $logMsg = "TUT email to SA Failed:  $_";
    my @exceptionMsg = split(/\n/, $_);
    my $emsg = "TUT email to SA Failed:  $exceptionMsg[0]";
    WriteEvent("A", $logMsg, $emsg);
}

Viewing all articles
Browse latest Browse all 29957

Latest Images

Trending Articles



Latest Images

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