Hauptmenü

Email-Versand mit ssmtp

Begonnen von cmonty14, 24 Februar 2017, 00:20:15

Vorheriges Thema - Nächstes Thema

cmonty14

Hallo!
Ich habe auf Raspi (Model B) ssmtp für den Mailversand eingerichtet.
Der Email-Versand funktioniert grundsätzlich:
root@pc6-raspi:~# ssmtp -v echo@tu-berlin.de
[<-] 220 smtp.gmail.com ESMTP m139sm47613wma.2 - gsmtp
[->] EHLO localhost
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO localhost
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcm5hbWU6
[->] NzRjbW9udHk=
[<-] 334 UGFzc3dvcmQ6
[<-] 235 2.7.0 Accepted
[->] MAIL FROM:<name@gmail.com>
[<-] 250 2.1.0 OK m139sm47613wma.2 - gsmtp
[->] RCPT TO:<echo@tu-berlin.de>
[<-] 250 2.1.5 OK m139sm47613wma.2 - gsmtp
[->] DATA
[<-] 354  Go ahead m139sm47613wma.2 - gsmtp
[->] Received: by localhost (sSMTP sendmail emulation); Thu, 23 Feb 2017 23:59:27 +0100
[->] From: "root" <name@gmail.com>
[->] Date: Thu, 23 Feb 2017 23:59:27 +0100
[->]
[->] .
[<-] 250 2.0.0 OK 1487890771 m139sm47613wma.2 - gsmtp
[->] QUIT
[<-] 221 2.0.0 closing connection m139sm47613wma.2 - gsmtp


Um den Mailversand mit FHEM zu nutzen habe ich die Datei /opt/fhem/FHEM/99_myUtils.pm angelegt:
##############################################
# $Id: myUtilsTemplate.pm 7570 2015-01-14 18:31:44Z rudolfkoenig $
#
# Save this file as 99_myUtils.pm, and create your own functions in the new
# file. They are then available in every Perl expression.

package main;

use strict;
use warnings;
use POSIX;

sub
myUtils_Initialize($$)
{
  my ($hash) = @_;
}

# Enter you functions below _this_ line.

####### E-Mailfunktion mit ssmtp ######################################
sub
ssmtpMail
{
my $rcpt = shift;
my $subject = shift;
my $text = shift;

local $SIG{CHLD} = 'DEFAULT';

my $returncode = system("echo '$text' | mail -s '$subject' '$rcpt'");
Log 1, "ssmtp RCP: $rcpt, Subject: $subject, Text: $text, Return: $returncode";
}

#1;


Wenn ich dann mit dem Befehl
{ssmtpMail('Empfänger@gmail.com','Betreff','TestTestTest')}
eine Email versenden will steht im Mail-Log:
Feb 23 23:46:20 pc6-raspi sSMTP[13550]: /etc/ssmtp/ssmtp.conf not found
Feb 23 23:46:20 pc6-raspi sSMTP[13550]: 530 5.7.0 Must issue a STARTTLS command first. a35sm7878524wra.21 - gsmtp

und es wird keine Email zugestellt.

Was ist die Ursache für dieses Problem?

THX