Wie Emails via PHP verschicken?

Benjamin83

Benutzer
Mitglied seit
09. Nov 2018
Beiträge
19
Punkte für Reaktionen
8
Punkte
53
Moin, und erstmal allen ein gures Jahr 2025!

Ich versuche seit Wochen (mit Unterbrechung natürlich) ein Kontaktformular für eine kleine Vereinswebseite zu realisieren. Ich hab auch schon im Mail Untefohrum gepostet, aber leider hat niemand reagiert: https://www.synology-forum.de/threads/versenden-von-ext-mails-aus-webstation-php-problem-mit-usern.136682/

Vielleicht habe ich ja hier mehr Glück - kann ja nicht der Einzige sein, der gerne Mails verschicken möchte...

Aber mal der Reihe nach:

Ich habe DSM 7.2.64570 und darauf in der Webstation 2 "Webportale":

  1. Eine private statische Hompage (Nur HTML): DomainA.de
  2. Eine Kontaktformular für einen kleinen Verein mit PHP 8.2: backend.DomainB.de
Die Systemmails von meiner Synology werden über einen externen Webserver (googlemail) versendet. Ein Mailserver war bisher auf der syno nicht installiert.
Ich habe jetzt "Synology Mail Server" installiert und die DomainB unter SMTP als Hostname (FQDN) eingetragen. (Ich habe es als Hostname wie auch als "Zusätliche Domain" ausporbiert, scheint keinen unterschied zu machen.
SMTP-Authentifizierung habe ich deaktiviert.
Testweise habe ich auch ein SMTP-Relay aktiviert. Das scheint zu funktionieren, ändert aber nicht viel am Problem.
DomainA benötigt keine Emails über die Syno.

Das PHP-Formular stammt von hier: https://www-coding.de/individuelles-kontaktformular-mit-captcha-in-php/
Der fürs versenden der Mails entscheidende Teil ist mMn das hier:



PHP:
$adminMail = 'webadmin@DomainB.de;
//$fromMail = "noreply@".$_SERVER['HTTP_HOST']; 
$fromMail = 'Info@DomainB.de';
...
mail($adminMail, $mailSubject, $mailText, $mailHeader."Content-type: text/plain; charset=utf-8"."\r\n");


Unter den Scriptspracheinstellungen habe ich den sendmail_path von PHP angepasst auf "/var/packages/MailServer/target/sbin/sendmail -t"
Ich kann das Formular erfolgreich aufrufen, auslösen und auch eine Mail generieren. Diese kommt bei "Synology Mail Server" an, aber nicht weiter.

Die Fehlermeldungen lassen immer wieder auf Probleme mit den Benutzen Usern schließen.
Ich habe also sowohl "Benutzernamen" als auch Domains im PHP benutzt die es in der Syno als lokale nutzer gibt, als auch solche die es nicht gibt.
Einen User "http" habe ich auf der Syno nicht, nur eine Gruppe.
Die Fehlermeldungen im postfix-Log des "Synology Mail Server" unterscheiden sich auch, aber weitergekommen bin ich mit keiner...

Ich habe stundenlang probiert und bin mir sicher ich stehe irgendwo auf dem Schlauch. Fragt sich nur wo...

Ich bin absolut nicht auf einen Lokalen Mailserver wie "Synology Mail Serve" fixiert. Von mir aus wäre es genauso i.O. die mail über den externen Mailserver von DomainB (Der den ich auch als Relay ausprobiert habe) zu versenden. Ich weiß nur nicht, wie man das mit PHP bewerkstelligt.

Im Endeffekt wäre ich selbst ein anderes Formular oder eine andere Websprache i.O. für mich, wir reden hier von einer Vereinsseite mit gerademal ein paar aufrufen - im Monat. Trozdem muss es hal eine Kontaktmöglichkeit geben.


Hier mal ein paar Beispiele für Vesuche dich ich gemacht habe:
  1. Relay in "Synology Mail Server" konfiguriert


    PHP:
    $adminMail = 'webadmin@DomainB.de';
    $fromMail = 'webadmin@DomainB.de';


    Postfix-Log:


    Code:
    2024-12-11T00:04:17+01:00 Synalogy postfix/pickup[11192]: 440AB2B3561: uid=1023 from=<http>
    2024-12-11T00:04:17+01:00 Synalogy postfix/cleanup[16664]: 440AB2B3561: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 440AB2B3561; Wed, 11 Dec 2024 00:04:17 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T00:04:17+01:00 Synalogy postfix/cleanup[16664]: 440AB2B3561: message-id=<20241210230417.440AB2B3561@DomainB.de>
    2024-12-11T00:04:17+01:00 Synalogy MailScanner[27753]: New Batch: Scanning 1 messages, 872 bytes
    2024-12-11T00:04:17+01:00 Synalogy MailScanner[27753]: Virus and Content Scanning: Starting
    2024-12-11T00:04:17+01:00 Synalogy MailScanner[27753]: Requeue: 440AB2B3561.A172A to B79322B356B
    2024-12-11T00:04:17+01:00 Synalogy MailScanner[27753]: Uninfected: Delivered 1 messages
    2024-12-11T00:04:17+01:00 Synalogy postfix/qmgr[11193]: B79322B356B: from=<http@DomainB.de>, size=597, nrcpt=1 (queue active)
    2024-12-11T00:04:17+01:00 Synalogy MailScanner[27753]: Deleted 1 messages from processing-database
    2024-12-11T00:04:17+01:00 Synalogy dovecot[16683]: lda(ben)<16683><gaOmIPHIWGcrQQAAb7vwnw>: sieve: msgid=<20241210230417.440AB2B3561@DomainB.de>: stored mail into mailbox 'INBOX'
    2024-12-11T00:04:17+01:00 Synalogy postfix/local[16682]: B79322B356B: to=<ben@DomainA.de>, relay=local, delay=0.31, delays=0.22/0.01/0/0.07, dsn=2.0.0, status=sent (delivered to command: /var/packages/MailServer/target/libexec/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT")
    2024-12-11T00:04:17+01:00 Synalogy postfix/qmgr[11193]: B79322B356B: removed
    2024-12-11T00:12:00+01:00 Synalogy postfix[20244]: Postfix is running with backwards-compatible default settings
    2024-12-11T00:12:00+01:00 Synalogy postfix[20244]: See http://www.postfix.org/COMPATIBILITY_README.html for details
    2024-12-11T00:12:00+01:00 Synalogy postfix[20244]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
    2024-12-11T00:12:00+01:00 Synalogy postfix/postfix-script[20290]: stopping the Postfix mail system
    2024-12-11T00:12:00+01:00 Synalogy postfix/master[11191]: terminating on signal 15
    2024-12-11T00:12:01+01:00 Synalogy postfix[20315]: Postfix is running with backwards-compatible default settings
    2024-12-11T00:12:01+01:00 Synalogy postfix[20315]: See http://www.postfix.org/COMPATIBILITY_README.html for details
    2024-12-11T00:12:01+01:00 Synalogy postfix[20315]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
    2024-12-11T00:12:02+01:00 Synalogy postfix/postfix-script[20361]: warning: not owned by root: /var/spool/postfix/.
    2024-12-11T00:12:02+01:00 Synalogy postfix/postfix-script[20369]: warning: group or other writable: /var/packages/MailServer/target/etc/./sasl2
    2024-12-11T00:12:02+01:00 Synalogy postfix/postfix-script[20370]: warning: group or other writable: /var/packages/MailServer/target/libexec/./dovecot/dovecot-auth
    2024-12-11T00:12:02+01:00 Synalogy postfix/postfix-script[20371]: warning: group or other writable: /var/packages/MailServer/target/libexec/./dovecot/deliver
    2024-12-11T00:12:02+01:00 Synalogy postfix/postfix-script[20383]: starting the Postfix mail system
    2024-12-11T00:12:02+01:00 Synalogy postfix/master[20385]: daemon started -- version 3.6.2, configuration /var/packages/MailServer/target/etc
    2024-12-11T00:13:17+01:00 Synalogy postfix/pickup[20386]: 6CDF82B35D3: uid=1023 from=<http>
    2024-12-11T00:13:17+01:00 Synalogy postfix/cleanup[20892]: 6CDF82B35D3: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 6CDF82B35D3; Wed, 11 Dec 2024 00:13:17 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T00:13:17+01:00 Synalogy postfix/cleanup[20892]: 6CDF82B35D3: message-id=<20241210231317.6CDF82B35D3@DomainB.de>
    2024-12-11T00:13:17+01:00 Synalogy MailScanner[27753]: New Batch: Scanning 1 messages, 887 bytes
    2024-12-11T00:13:17+01:00 Synalogy MailScanner[27753]: Virus and Content Scanning: Starting
    2024-12-11T00:13:17+01:00 Synalogy MailScanner[27753]: Requeue: 6CDF82B35D3.A1D3D to 0C8142B35DD
    2024-12-11T00:13:17+01:00 Synalogy MailScanner[27753]: Uninfected: Delivered 1 messages
    2024-12-11T00:13:17+01:00 Synalogy postfix/qmgr[20387]: 0C8142B35DD: from=<http@DomainB.de>, size=612, nrcpt=1 (queue active)
    2024-12-11T00:13:17+01:00 Synalogy MailScanner[27753]: Deleted 1 messages from processing-database
    2024-12-11T00:13:17+01:00 Synalogy dovecot[20934]: lda(ben)<20934><+m6tKQ3LWGfGUQAAb7vwnw>: sieve: msgid=<20241210231317.6CDF82B35D3@DomainB.de>: stored mail into mailbox 'INBOX'
    2024-12-11T00:13:17+01:00 Synalogy postfix/local[20933]: 0C8142B35DD: to=<ben@DomainA.de>, relay=local, delay=0.29, delays=0.21/0.01/0/0.07, dsn=2.0.0, status=sent (delivered to command: /var/packages/MailServer/target/libexec/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT")
    2024-12-11T00:13:17+01:00 Synalogy postfix/qmgr[20387]: 0C8142B35DD: removed
    2024-12-11T00:15:56+01:00 Synalogy postfix/pickup[20386]: 8FBD72B35F5: uid=1023 from=<http>
    2024-12-11T00:15:56+01:00 Synalogy postfix/cleanup[21930]: 8FBD72B35F5: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 8FBD72B35F5; Wed, 11 Dec 2024 00:15:56 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T00:15:56+01:00 Synalogy postfix/cleanup[21930]: 8FBD72B35F5: message-id=<20241210231556.8FBD72B35F5@DomainB.de>
    2024-12-11T00:15:58+01:00 Synalogy MailScanner[27794]: New Batch: Scanning 1 messages, 889 bytes
    2024-12-11T00:15:58+01:00 Synalogy MailScanner[27794]: Virus and Content Scanning: Starting
    2024-12-11T00:15:58+01:00 Synalogy MailScanner[27794]: Requeue: 8FBD72B35F5.A2047 to 7A6362B35FF
    2024-12-11T00:15:58+01:00 Synalogy postfix/qmgr[20387]: 7A6362B35FF: from=<http@DomainB.de>, size=605, nrcpt=1 (queue active)
    2024-12-11T00:15:58+01:00 Synalogy MailScanner[27794]: Uninfected: Delivered 1 messages
    2024-12-11T00:15:58+01:00 Synalogy postfix/local[21974]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T00:15:58+01:00 Synalogy postfix/local[21974]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T00:15:58+01:00 Synalogy postfix/local[21974]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T00:15:58+01:00 Synalogy MailScanner[27794]: Deleted 1 messages from processing-database
    2024-12-11T00:15:58+01:00 Synalogy postfix/local[21974]: 7A6362B35FF: to=<webadmin@DomainB.de>, relay=local, delay=2, delays=2/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "webadmin")
    2024-12-11T00:15:58+01:00 Synalogy postfix/cleanup[21930]: 8A0DC2B3603: message-id=<20241210231558.8A0DC2B3603@DomainB.de>
    2024-12-11T00:15:58+01:00 Synalogy postfix/bounce[21975]: 7A6362B35FF: sender non-delivery notification: 8A0DC2B3603
    2024-12-11T00:15:58+01:00 Synalogy postfix/bounce[21975]: get message_id fail
    2024-12-11T00:15:58+01:00 Synalogy postfix/qmgr[20387]: 8A0DC2B3603: from=<>, size=2495, nrcpt=1 (queue active)
    2024-12-11T00:15:58+01:00 Synalogy postfix/qmgr[20387]: 7A6362B35FF: removed
    2024-12-11T00:15:58+01:00 Synalogy postfix/local[21974]: 8A0DC2B3603: to=<http@DomainB.de>, relay=local, delay=0.01, delays=0/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "http")
    2024-12-11T00:15:58+01:00 Synalogy postfix/qmgr[20387]: 8A0DC2B3603: removed
    2024-12-11T16:27:17+01:00 Synalogy postfix/pickup[11774]: 9681E2B4DF5: uid=1023 from=<http>
    2024-12-11T16:27:17+01:00 Synalogy postfix/cleanup[31922]: 9681E2B4DF5: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 9681E2B4DF5; Wed, 11 Dec 2024 16:27:17 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T16:27:17+01:00 Synalogy postfix/cleanup[31922]: 9681E2B4DF5: message-id=<20241211152717.9681E2B4DF5@DomainB.de>
    2024-12-11T16:27:18+01:00 Synalogy MailScanner[27794]: New Batch: Scanning 1 messages, 901 bytes
    2024-12-11T16:27:18+01:00 Synalogy MailScanner[27794]: Virus and Content Scanning: Starting
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[27794]: Requeue: 9681E2B4DF5.A0ABD to AD4E62B4DFF
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[27794]: Uninfected: Delivered 1 messages
    2024-12-11T16:27:19+01:00 Synalogy postfix/qmgr[20387]: AD4E62B4DFF: from=<http@DomainB.de>, size=617, nrcpt=1 (queue active)
    2024-12-11T16:27:19+01:00 Synalogy postfix/local[31941]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T16:27:19+01:00 Synalogy postfix/local[31941]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T16:27:19+01:00 Synalogy postfix/local[31941]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[27794]: Deleted 1 messages from processing-database
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[27794]: MailScanner child dying of old age
    2024-12-11T16:27:19+01:00 Synalogy postfix/local[31941]: AD4E62B4DFF: to=<webadmin@DomainB.de>, relay=local, delay=1.5, delays=1.5/0.02/0/0.02, dsn=5.1.1, status=bounced (unknown user: "webadmin")
    2024-12-11T16:27:19+01:00 Synalogy postfix/cleanup[31922]: 13CAD2B4E03: message-id=<20241211152719.13CAD2B4E03@DomainB.de>
    2024-12-11T16:27:19+01:00 Synalogy postfix/bounce[31942]: AD4E62B4DFF: sender non-delivery notification: 13CAD2B4E03
    2024-12-11T16:27:19+01:00 Synalogy postfix/qmgr[20387]: 13CAD2B4E03: from=<>, size=2507, nrcpt=1 (queue active)
    2024-12-11T16:27:19+01:00 Synalogy postfix/qmgr[20387]: AD4E62B4DFF: removed
    2024-12-11T16:27:19+01:00 Synalogy postfix/local[31941]: 13CAD2B4E03: to=<http@DomainB.de>, relay=local, delay=0.01, delays=0/0/0/0, dsn=5.1.1, status=bounced (unknown user: "http")
    2024-12-11T16:27:19+01:00 Synalogy postfix/qmgr[20387]: 13CAD2B4E03: removed
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: MailScanner E-Mail Virus Scanner version 4.84.5 starting...
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Reading configuration file /var/packages/MailServer/target/etc/MailScanner/MailScanner.conf
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Reading configuration file /var/packages/MailServer/target/etc/MailScanner/conf.d/README
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Read 869 hostnames from the phishing whitelist
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Read 3531 hostnames from the phishing blacklists
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Using SpamAssassin results cache
    2024-12-11T16:27:19+01:00 Synalogy MailScanner[31973]: Connected to SpamAssassin cache database
    2024-12-11T16:27:23+01:00 Synalogy MailScanner[31973]: Connected to Processing Attempts Database
    2024-12-11T16:27:23+01:00 Synalogy MailScanner[31973]: Found 0 messages in the Processing Attempts Database
    2024-12-11T16:27:23+01:00 Synalogy MailScanner[31973]: Your "Incoming Work Directory" should be specified as an absolute path, not including any links. But I will work okay anyway.
    2024-12-11T16:27:23+01:00 Synalogy MailScanner[31973]: Using locktype = flock



  2. Relay in "Synology Mail Server" konfiguriert




    PHP:
    $adminMail = 'webadmin@em-hansele.de';
    $fromMail = "noreply@".$_SERVER['HTTP_HOST'];






    Code:
    2024-12-11T21:04:54+01:00 Synalogy postfix/pickup[1044]: 967562B534E: uid=1023 from=<http>
    2024-12-11T21:04:54+01:00 Synalogy postfix/cleanup[13876]: 967562B534E: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 967562B534E; Wed, 11 Dec 2024 21:04:54 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T21:04:54+01:00 Synalogy postfix/cleanup[13876]: 967562B534E: message-id=<20241211200454.967562B534E@DomainB.de>
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: New Batch: Scanning 1 messages, 906 bytes
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: Virus and Content Scanning: Starting
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: Requeue: 967562B534E.A0276 to 473072B5358
    2024-12-11T21:04:56+01:00 Synalogy postfix/qmgr[20387]: 473072B5358: from=<http@DomainB.de>, size=622, nrcpt=1 (queue active)
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: Uninfected: Delivered 1 messages
    2024-12-11T21:04:56+01:00 Synalogy postfix/local[13917]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:04:56+01:00 Synalogy postfix/local[13917]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:04:56+01:00 Synalogy postfix/local[13917]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: Deleted 1 messages from processing-database
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[27714]: MailScanner child dying of old age
    2024-12-11T21:04:56+01:00 Synalogy postfix/local[13917]: 473072B5358: to=<webadmin@DomainB.de>, relay=local, delay=1.7, delays=1.7/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "webadmin")
    2024-12-11T21:04:56+01:00 Synalogy postfix/cleanup[13876]: 4408E2B535C: message-id=<20241211200456.4408E2B535C@DomainB.de>
    2024-12-11T21:04:56+01:00 Synalogy postfix/bounce[13918]: 473072B5358: sender non-delivery notification: 4408E2B535C
    2024-12-11T21:04:56+01:00 Synalogy postfix/bounce[13918]: get message_id fail
    2024-12-11T21:04:56+01:00 Synalogy postfix/qmgr[20387]: 4408E2B535C: from=<>, size=2512, nrcpt=1 (queue active)
    2024-12-11T21:04:56+01:00 Synalogy postfix/qmgr[20387]: 473072B5358: removed
    2024-12-11T21:04:56+01:00 Synalogy postfix/local[13917]: 4408E2B535C: to=<http@DomainB.de>, relay=local, delay=0.02, delays=0.01/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "http")
    2024-12-11T21:04:56+01:00 Synalogy postfix/qmgr[20387]: 4408E2B535C: removed
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: MailScanner E-Mail Virus Scanner version 4.84.5 starting...
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Reading configuration file /var/packages/MailServer/target/etc/MailScanner/MailScanner.conf
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Reading configuration file /var/packages/MailServer/target/etc/MailScanner/conf.d/README
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Read 869 hostnames from the phishing whitelist
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Read 3531 hostnames from the phishing blacklists
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Using SpamAssassin results cache
    2024-12-11T21:04:56+01:00 Synalogy MailScanner[13924]: Connected to SpamAssassin cache database
    2024-12-11T21:05:00+01:00 Synalogy MailScanner[13924]: Connected to Processing Attempts Database
    2024-12-11T21:05:00+01:00 Synalogy MailScanner[13924]: Found 0 messages in the Processing Attempts Database
    2024-12-11T21:05:00+01:00 Synalogy MailScanner[13924]: Your "Incoming Work Directory" should be specified as an absolute path, not including any links. But I will work okay anyway.
    2024-12-11T21:05:00+01:00 Synalogy MailScanner[13924]: Using locktype = flock



  3. Relay in "Synology Mail Server" ausgeschaltet


    PHP:
    $adminMail = 'webadmin@em-hansele.de';
    $fromMail = "noreply@".$_SERVER['HTTP_HOST'];



    Code:
    2024-12-11T21:09:17+01:00 Synalogy postfix[16055]: See http://www.postfix.org/COMPATIBILITY_README.html for details
    2024-12-11T21:09:17+01:00 Synalogy postfix[16055]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
    2024-12-11T21:09:17+01:00 Synalogy postfix/postfix-script[16062]: stopping the Postfix mail system
    2024-12-11T21:09:17+01:00 Synalogy postfix/master[20385]: terminating on signal 15
    2024-12-11T21:09:18+01:00 Synalogy postfix[16088]: Postfix is running with backwards-compatible default settings
    2024-12-11T21:09:18+01:00 Synalogy postfix[16088]: See http://www.postfix.org/COMPATIBILITY_README.html for details
    2024-12-11T21:09:18+01:00 Synalogy postfix[16088]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
    2024-12-11T21:09:19+01:00 Synalogy postfix/postfix-script[16135]: warning: not owned by root: /var/spool/postfix/.
    2024-12-11T21:09:19+01:00 Synalogy postfix/postfix-script[16143]: warning: group or other writable: /var/packages/MailServer/target/etc/./sasl2
    2024-12-11T21:09:19+01:00 Synalogy postfix/postfix-script[16144]: warning: group or other writable: /var/packages/MailServer/target/libexec/./dovecot/dovecot-auth
    2024-12-11T21:09:19+01:00 Synalogy postfix/postfix-script[16145]: warning: group or other writable: /var/packages/MailServer/target/libexec/./dovecot/deliver
    2024-12-11T21:09:19+01:00 Synalogy postfix/postfix-script[16156]: starting the Postfix mail system
    2024-12-11T21:09:19+01:00 Synalogy postfix/master[16158]: daemon started -- version 3.6.2, configuration /var/packages/MailServer/target/etc
    2024-12-11T21:10:00+01:00 Synalogy postfix/pickup[16159]: 7960A2B53A8: uid=1023 from=<http>
    2024-12-11T21:10:00+01:00 Synalogy postfix/cleanup[16474]: 7960A2B53A8: hold: header Received: by DomainB.de (Postfix, from userid 1023)??id 7960A2B53A8; Wed, 11 Dec 2024 21:10:00 +0100 (CET) from local; from=<http@DomainB.de>
    2024-12-11T21:10:00+01:00 Synalogy postfix/cleanup[16474]: 7960A2B53A8: message-id=<20241211201000.7960A2B53A8@DomainB.de>
    2024-12-11T21:10:00+01:00 Synalogy MailScanner[13924]: New Batch: Scanning 1 messages, 981 bytes
    2024-12-11T21:10:00+01:00 Synalogy MailScanner[13924]: Virus and Content Scanning: Starting
    2024-12-11T21:10:00+01:00 Synalogy MailScanner[13924]: Requeue: 7960A2B53A8.A07C6 to 4309D2B53B2
    2024-12-11T21:10:00+01:00 Synalogy MailScanner[13924]: Uninfected: Delivered 1 messages
    2024-12-11T21:10:00+01:00 Synalogy postfix/qmgr[16160]: 4309D2B53B2: from=<http@DomainB.de>, size=697, nrcpt=1 (queue active)
    2024-12-11T21:10:00+01:00 Synalogy postfix/local[16492]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:10:00+01:00 Synalogy MailScanner[13924]: Deleted 1 messages from processing-database
    2024-12-11T21:10:00+01:00 Synalogy postfix/local[16492]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:10:00+01:00 Synalogy postfix/local[16492]: postfix: SLIBUserRealNameGet(user=webadmin) failed
    2024-12-11T21:10:00+01:00 Synalogy postfix/local[16492]: 4309D2B53B2: to=<webadmin@DomainB.de>, relay=local, delay=0.21, delays=0.18/0.02/0/0.01, dsn=5.1.1, status=bounced (unknown user: "webadmin")
    2024-12-11T21:10:00+01:00 Synalogy postfix/cleanup[16474]: A962C2B53B6: message-id=<20241211201000.A962C2B53B6@DomainB.de>
    2024-12-11T21:10:00+01:00 Synalogy postfix/qmgr[16160]: A962C2B53B6: from=<>, size=2587, nrcpt=1 (queue active)
    2024-12-11T21:10:00+01:00 Synalogy postfix/bounce[16493]: 4309D2B53B2: sender non-delivery notification: A962C2B53B6
    2024-12-11T21:10:00+01:00 Synalogy postfix/qmgr[16160]: 4309D2B53B2: removed
    2024-12-11T21:10:00+01:00 Synalogy postfix/local[16492]: A962C2B53B6: to=<http@DomainB.de>, relay=local, delay=0.02, delays=0/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "http")
    2024-12-11T21:10:00+01:00 Synalogy postfix/qmgr[16160]: A962C2B53B6: removed

 

Benjamin83

Benutzer
Mitglied seit
09. Nov 2018
Beiträge
19
Punkte für Reaktionen
8
Punkte
53
schau dir mal PHPMailer an...
Hab ich getan, bin leider auch nicht weitergekommen. Zum einen fehlt PEAR seit DSM7 in den Paketen, und zum anderen hab ich auch kein brauchbares Tutorian / nutzbares Formular gefunden.
 

DaveR

Benutzer
Sehr erfahren
Mitglied seit
30. Mrz 2022
Beiträge
379
Punkte für Reaktionen
723
Punkte
144
You can use ssmtp to send emails from a Synology. To use ssmtp you need to setup email notifications in "Control Panel > Notification > Email > click on Setup button" .

In bash scripts I use:

Bash:
# Send email function
# shellcheck disable=SC2329  # Invoked indirectly
send_email(){
    # $1 is $to_email_address
    # $2 is $from_email_address
    # $3 is $Backup_Directory
    # $4 is $email_contents"
    # $5 is $subject
    # $6 is $mail_body


    if [[ ! -f "$Log_File" ]]; then
        echo -e "\nWARNING Cannot send email as directory $Log_File does not exist"\
            |& tee -a "${Err_Log_File}"
    elif [[ "${3}" == "" || "${4}" == "" ]]; then
        echo -e "\nWARNING Send email failed. Incorrect data was passed to \"send_email\" function"\
            |& tee -a "${Err_Log_File}"
    else
        if [[ -d "${3}" ]]; then  # Make sure directory exists
            if [[ -w "${3}" ]]; then  # Make sure directory is writable
                if [[ -r "${3}" ]]; then  # Make sure directory is readable
                    echo "To: ${1} " > "${3}/${4}"
                    echo "From: ${2} " >> "${3}/${4}"
                    echo "Subject: ${5}" >> "${3}/${4}"
                    echo "" >> "${3}/${4}"
                    cat "$Log_File" >> "${3}/${4}"


                    #if [[ "${1}" == "" || "${2}" == "" || "${5}" == "" || "${6}" == "" ]]; then
                    if [[ "${1}" == "" || "${2}" == "" || "${5}" == "" ]]; then
                        echo -e "\nWARNING One or more email address parameters [to, from, subject,"\
                            "mail_body] was not supplied, Cannot send an email" |& tee -a "${Log_File}"
                    else
                        if ! command -v ssmtp &> /dev/null  # Verify the ssmtp command is available
                        then
                            echo -e "\nWARNING Cannot Send Email as command \"ssmtp\" was not found"\
                                |& tee -a "${Log_File}"
                        else
                            local email_response
                            email_response=$(ssmtp "${1}" < "${3}/${4}"  2>&1)
                            if [[ "$email_response" == "" ]]; then
                                domain=$(echo "$to_email_address" | awk -F '@' '{print $NF}')
                                echo -e "Email sent successfully to $domain" |& tee -a "${Log_File}"
                            else
                                echo -e "\nWARNING An error occurred while sending email."\
                                    "The error was: $email_response\n\n" |& tee -a "${Log_File}"
                            fi   
                        fi
                    fi
                else
                    echo -e "Cannot send email as directory \"${3}\" does not have READ permissions"\
                        |& tee -a "${Log_File}"
                fi
            else
                echo -e "Cannot send email as directory \"${3}\" does not have WRITE permissions"\
                    |& tee -a "${Log_File}"
            fi
        else
            echo -e "Cannot send email as directory \"${3}\" does not exist" |& tee -a "${Log_File}"
        fi
    fi
}

# Send log via email if both logging and emails are enabled
if [[ $to_email_address && $from_email_address ]]; then
    echo -e "\nSending email..."
    email_contents="email_contents.txt"
    send_email "$to_email_address" "$from_email_address" "$Backup_Directory"  "$email_contents" "$Nas - $script log"
fi

You should be to strip out what you need and convert it to php.
 
  • Like
Reaktionen: maxblank und Tommes

Tommes

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
26. Okt 2009
Beiträge
9.809
Punkte für Reaktionen
1.769
Punkte
314
@DaveR Do you know if or how to send file attachments using ssmtp?
 

DaveR

Benutzer
Sehr erfahren
Mitglied seit
30. Mrz 2022
Beiträge
379
Punkte für Reaktionen
723
Punkte
144
I believe ssmtp is the same as msmtp, and you can't send attachments with msmtp.

Mutt works with the same commands as msmtp (as mutt has smtp built-in) but mutt also supports emailing attachments. Replacing "msmtp" with "mutt" in my code above works.

To use mutt to send an attachment. Something like the following should work but I've not tried it.

mutt -a /path/to/attachment.ext "${1}" < "${3}/${4}"

or

mutt -a /path/to/attachment.txt -s subject — recipient@domain.com < /path/to/body.txt

In DSM you can install mutt from synocommunity.

1735983923269.png
 
  • Like
Reaktionen: Tommes und maxblank

Tommes

Benutzer
Sehr erfahren
Maintainer
Mitglied seit
26. Okt 2009
Beiträge
9.809
Punkte für Reaktionen
1.769
Punkte
314
I will definitely save the ssmtp script and have a look at Mutt in the coming days. At the moment I have only asked for someone else. Thanks for your help.
 


 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat