#!/usr/bin/perl use strict; use warnings; use Net::SMTPS; use Authen::SASL; my $user = 'postausgangFHEM@domain.de'; my $pass = 'KnAM'; my $sender = 'fhem@domain.de'; my $rcpt = 'marc@domain.de'; my $server = 'smtp.strato.de'; my $domain = 'www.strato.de'; my $mail_sasl_type = 'starttls'; my $server_port = 587; my $smtp = Net::SMTPS->new( $server, Port => $server_port, Debug => 1, doSSL => $mail_sasl_type) || die "cannot connect to server ${server}"; my $sasl = Authen::SASL->new( mechanism => 'PLAIN', debug => 1, callback => {pass => $pass, user => $user}); $smtp->auth( $sasl ) || die "cannot do mail auth"; $smtp->mail($sender) or die "Error:".$smtp->message(); $smtp->to($rcpt) or die "Error:".$smtp->message(); $smtp->data() or die "Error:".$smtp->message(); $smtp->datasend("Subject: Mein Subject\n"); $smtp->datasend("\n"); $smtp->datasend("Mein Body"); $smtp->dataend() or die "Error:".$smtp->message(); $smtp->quit() or die "Error:".$smtp->message(); #### root@schneckenFhem:/opt/fhem# perl ./FHEM/sendEmail.pm Net::SMTPS>>> Net::SMTPS(0.09) Net::SMTPS>>> IO::Socket::IP(0.39) Net::SMTPS>>> IO::Socket(1.39) Net::SMTPS>>> IO::Handle(1.39) Net::SMTPS>>> Exporter(5.73) Net::SMTPS>>> Net::SMTP(3.11) Net::SMTPS>>> Net::Cmd(3.11) Net::SMTPS=GLOB(0x562fb253e128)<<< 220 smtp.strato.de ESMTP RZmta (P12 -) Net::SMTPS=GLOB(0x562fb253e128)>>> EHLO localhost.localdomain Net::SMTPS=GLOB(0x562fb253e128)<<< 250-smtp.strato.de greets 89.244.230.217 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-ENHANCEDSTATUSCODES Net::SMTPS=GLOB(0x562fb253e128)<<< 250-PIPELINING Net::SMTPS=GLOB(0x562fb253e128)<<< 250-8BITMIME Net::SMTPS=GLOB(0x562fb253e128)<<< 250-DELIVERBY Net::SMTPS=GLOB(0x562fb253e128)<<< 250-SIZE 104857600 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-STARTTLS Net::SMTPS=GLOB(0x562fb253e128)<<< 250-BURL imap Net::SMTPS=GLOB(0x562fb253e128)<<< 250-CHUNKING Net::SMTPS=GLOB(0x562fb253e128)<<< 250 HELP Net::SMTPS=GLOB(0x562fb253e128)>>> STARTTLS Net::SMTPS=GLOB(0x562fb253e128)<<< 220 Ready to start TLS Net::SMTPS=GLOB(0x562fb253e128)>>> EHLO localhost.localdomain Net::SMTPS=GLOB(0x562fb253e128)<<< 250-smtp.strato.de greets 89.244.230.217 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-ENHANCEDSTATUSCODES Net::SMTPS=GLOB(0x562fb253e128)<<< 250-PIPELINING Net::SMTPS=GLOB(0x562fb253e128)<<< 250-8BITMIME Net::SMTPS=GLOB(0x562fb253e128)<<< 250-DELIVERBY Net::SMTPS=GLOB(0x562fb253e128)<<< 250-SIZE 104857600 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5 Net::SMTPS=GLOB(0x562fb253e128)<<< 250-REQUIRETLS Net::SMTPS=GLOB(0x562fb253e128)<<< 250-BURL imap Net::SMTPS=GLOB(0x562fb253e128)<<< 250-CHUNKING Net::SMTPS=GLOB(0x562fb253e128)<<< 250 HELP cannot do mail auth at ./FHEM/sendEmail.pm line 20.