Hi !
Ich hab o.g. aus dem Wiki in 99_myUtils,pm kopiert (1:1) auch habe ich die 99_myUtils.pm erstell wie im Wiki beschrieben, aber trotzdem findet er das Kommando im der fhem Commandline nicht (und meckern tut er bei laden der 99_myUtils.pm auch nicht)
##############################################
# $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 Blocking;
use strict;
use warnings;
use POSIX;
sub
myUtils_Initialize($$)
{
my ($hash) = @_;
}
# Enter you functions below _this_ line.
##############################################################################
######## DebianMail Mail versenden nonblocking ############
##############################################################################
sub DebianMailnbl {
my $rcpt = shift;
my $subject = shift;
my $text = shift;
my $attach = shift;
my $attach1 = shift;
my $attach2 = shift;
my $hash->{NAME_MAIL} = "Debianmail";
my $name = $hash->{NAME_MAIL};
if ($attach2) {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach." |".$attach1."|".$attach2, "", "", "", "");}
elsif ($attach1) {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach."|" .$attach1, "", "", "", "");
} else {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach,"", "", "", "");
}
}
######################################################
######## Mailfunktion nonblocking
######################################################
sub DebianMailnbl_send {
my ($string) = @_;
my ($name, $rcpt, $subject, $text, $attach, $attach1, $attach2) = split("\\|", $string);
my $ret = "";
my $sender = "fhem\@irgendwo";
my $konto = "fhem";
my $passwrd = "password";
my $provider = "smtp.irgendwo.net";
if ($attach2) {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -a '$attach1' -a '$attach2' -s '$provider' \
-xu '$konto' -xp '$passwrd' -o tls=auto -o message -charset=utf-8 -o message-content-type=text/plain );
} elsif ($attach1) {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -a '$attach1' -s '$provider' -xu '$konto' \
-xp '$passwrd' -o tls=auto -o message-charset=utf-8 -o message-content-type=text/plain );
} else {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -s '$provider' -xu '$konto' -xp '$passwrd' \
-o tls=auto -o message-charset=utf-8 -o message-content-type=text/plain );
}
# remove CR from return-string
$ret =~ s,[\r\n]*,,g;
Log3 $name, 3, "$name - sendemail returned: $ret";
}
1;
Schön, dass du alles 1:1 kopiert hast. Hast du auch das Paket sendemail installiert?
("Man" könnte ggf. das Wiki um diesen Hinweis nachbessern, bräuchte aber einen Hinweis, auf welche der Anleitungen im Wiki du dich konkret beziehst...)
Und dann: bitte selbst (!) nach Anfängerfragen verschieben. Dieser Forumsbereich ist für funktionierenden Code!
Ich vermute eher er ruft DebianMailnbl falsch auf, nämlich als fhem Kommando. Es muss aber als Perl Code aufgerufen werden {DebianMailnbl}.
ok gesagt getan
bezogen hab ich mich auf diesen https://wiki.fhem.de/wiki/SSCAM_-_Steuerung_von_Kameras_in_Synology_Surveillance_Station#Mail_mit_Snapshot_im_Anhang_und_Aufnahmelink_versenden_.28sendEmail.29 (https://wiki.fhem.de/wiki/SSCAM_-_Steuerung_von_Kameras_in_Synology_Surveillance_Station#Mail_mit_Snapshot_im_Anhang_und_Aufnahmelink_versenden_.28sendEmail.29) wiki eintrag
Und die sendmail ist installiert
odroid@smarthome:~$ send
sendemail sendEmail
Aufruf fhem> {DebianMailnbl ('gerd@hoerst','Batteriewarnung!','Foldende Device haben niedrigen Batteriestand:')}
Ausgabe in der Kommandozeile (das scheint ja so zu passen
HASH(0x1bb0060)
Aber: fhem logfile
sh: 2: -o: not found
mail geht natuerlich keine raus....
Gruss Gerd
Zitat von: Beta-User am 05 Dezember 2019, 09:28:19
Und dann: bitte selbst (!) nach Anfängerfragen verschieben. Dieser Forumsbereich ist für funktionierenden Code!
wie funktioniert das ?
Du musst in deinem ersten Beitrag unten links schauen.
Und hast Du im Wiki diesen Satz gelesen?
ZitatDie "\" dienen nachfolgend nur zur Kennzeichnung eines Zeilenumbruchs - den Code bitte auf eine Zeile schreiben.
Gruß Otto
Zitat von: goerdi am 05 Dezember 2019, 10:02:36
wie funktioniert das ?
In welcher Gruppe sollte ich meine Fragen stellen (https://forum.fhem.de/index.php/topic,13092.0.html)
hi ! So jetzt bin ich richtig :)
mit {DebianMailnbl ('gerd@irgendwo','testsubjekt','Testtext')} in der Kommandozeile gehts nun....
Ich hab das Modul mal abgeaendert das es auch ohne Attachments funktioniert... (anscheinend wollte das Modul unbedingt ein attachment sehen...)
Hier mal das Modul:
##############################################################################
######## DebianMail Mail versenden nonblocking ############
##############################################################################
sub DebianMailnbl {
my $rcpt = shift;
my $subject = shift;
my $text = shift;
my $attach = shift;
my $attach1 = shift;
my $attach2 = shift;
my $hash->{NAME_MAIL} = "Debianmail";
my $name = $hash->{NAME_MAIL};
if ($attach2) {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach."|".$attach1."|".$attach2, "", "", "", "");
} elsif ($attach1) {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach."|".$attach1, "", "", "", "");
} elsif ($attach) {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|".$attach,"", "", "", "");
} else {
$hash->{helper}{RUNNING_PID} = BlockingCall("DebianMailnbl_send", $name."|".$rcpt."|".$subject."|".$text."|","", "", "", "");
}
}
######################################################
######## Mailfunktion nonblocking
######################################################
sub DebianMailnbl_send {
my ($string) = @_;
my ($name, $rcpt, $subject, $text, $attach, $attach1, $attach2) = split("\\|", $string);
my $ret = "";
my $sender = "fhem\@server";
my $konto = "fhem";
my $passwrd = "passwd";
my $provider = "smtp.server";
if ($attach2) {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -a '$attach1' -a '$attach2' -s '$provider' -xu '$konto' -xp '$passwrd' -o tls=auto -o message -charset=utf-8 -o message-content-type=text/plain );
} elsif ($attach1) {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -a '$attach1' -s '$provider' -xu '$konto' -xp '$passwrd' -o tls=auto -o message-charset=utf-8 -o message-content-type=text/plain );
} elsif ($attach) {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -a '$attach' -s '$provider' -xu '$konto' -xp '$passwrd' -o tls=auto -o message-charset=utf-8 -o message-content-type=text/plain );
} else {
$ret .= qx(sendemail -f '$sender' -t '$rcpt' -u '$subject' -m '$text' -s '$provider' -xu '$konto' -xp '$passwrd' -o tls=auto -o message-charset=utf-8 -o message-content-type=text/plain );
}
# remove CR from return-string
$ret =~ s,[\r\n]*,,g;
Log3 $name, 3, "$name - sendemail returned: $ret";
}
Ok ich hab es mit tls auto....
Gruss Gerd