ljunkie / plexWatch

Notify and Log watched content on a Plex Media Server
430 stars 59 forks source link

EMAIL error: Can't call method "mail" on an undefined value #89

Closed hdurdle closed 7 years ago

hdurdle commented 9 years ago

Environment plexwatch.exe on Windows Server 2012 R2 (fully patched) and plexwatch.pl perl script under ActivePerl x64 v5.20.2 on the same system.

Using the default config.pl-dist-win32 renamed to config.pl with an SMTP server added (mailhost.zen.co.uk, my ISPs "open" relay) and with the 'to' and 'from' addresses populated, I set 'enabled' to 1. No auth required for this SMTP server.

Issue If I run plexwatch.pl --test_notify=start I receive this error:

EMAIL error: Can't call method "mail" on an undefined value at plexwatch.pl line 2872.
EMAIL failed: - setting EMAIL to back off additional notifications

I get exactly the same error if I use the Windows executable.

There is no firewall blocking access - I can telnet to port 25 of that SMTP server from the affected machine and manually send an email which is successfully delivered.

The account running the script (or .exe) has full control over all the files it needs to read or touch.

Other command lines work perfectly (so plexwatch.exe --watched returns the data I'd expect).

What can I try next?

Partially redacted EMAIL config section:

'EMAIL' => {

    '1' =>  {
        'enabled' => 1, ## set to 1 to enable local EMAIL
        'push_recentlyadded'  => 0,
        'push_watched'        => 1,
        'push_watching'       => 1,
        'push_paused'         => 1,
        'push_resumed'        => 1,
        'server' => 'mailhost.zen.co.uk', # your mail server
        'port' => '25', # your mail server port defalt 25 (587 is also a good choice)
        'from' => 'xxxx@xxxx.xxxx',   # your From email address: 'user@domain.com'
        'to' => 'xxxx@xxxx.xxxx',     # Email address to receive notification: 'user@domain.com'
        'username' => '', # AUTH if needed [optional]
        'password' => '', # AUTH if needed [optional]
        'subject' => '{user} {push_title} {title}', ## push_title is special for EMAIL (for now)
        'enable_tls' => 0,  # ENABLE for TLS support ( your smtp server must allow STARTTLS )
        'alert_format' => {
            'start'    =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] {ip_address} {all_details}',
            'paused'   =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] [{percent_complete}%] {ip_address} {all_details}',
            'resumed'  =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] [{percent_complete}%] {ip_address} {all_details}',
            'stop'     =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} for {duration} [{percent_complete}%] {ip_address} {all_details}',
        },
    },

},
MikeFalcor commented 9 years ago

Have you tried enabling TLS? Try it and see what happens.

ljunkie commented 9 years ago

I'd stick with the .exe as you'd need the perfect environment setup for it to work, and the stock activeperl or strawberry perl will not work perfectly, even with the right perl modules. The .exe is bundled, so it just works and doesn't require perl at all.

The only suggesting I'd have right now is to test using a gmail account and a stock config.

hdurdle commented 9 years ago

Turning on TLS with no other changes resulted in the same error.

Leaving my config.pl intact, but adding smtp.gmail.com with a valid username and password, and turning on TLS works.

I've tried several unauthenticated servers (either on my local network, or my ISPs) and have received the same error each time.

Should the script/underlying Perl module be able to send via an unauthenticated and unencrypted SMTP server?

cemeyer2 commented 7 years ago

FWIW, i fixed this same issue on my system by replacing localhost with 127.0.0.1 in the config