PHPMailer funktioniert mit neuer IPS Version 7 nicht mehr

Ich verstehe die Installationsanleitung so, dass es mehrere Wege gibt.

Zitat: " Alternatively, if you’re not using Composer, you can download PHPMailer as a zip file, …"

Das war wohl eher ein Kopierfehler…

Du bist aber hartnäckig, da sind doch wieder drei Punkte drin!

require '…/vendor/autoload.php';

Benutze bitte die Funktion Vorformatierter Text vom Forum, sonst wird man deinen Code nie 1:1 im Forum lesen können.
Danke.
Michael

Schau dort nochmal die Anleitung zur manuellen Installation genauer an, da steht auch dieser Satz:
„Even if you’re not using exceptions, you do still need to load the Exception class as it is used internally.“

Das dürfte diesen von dir berichteten Fehler erklären:
Fatal error: Uncaught Error: Class „PHPMailer\PHPMailer\Exception“ not found in C:\ProgramData\Symcon\scripts\PHPMailer\PHPMailer.php:1615

In der Installationsanleitung steht die Einbindung beschrieben.

Ganz herzlichen Dank an alle helfenden Hände!!!

Die Zeile

    use PHPMailer\PHPMailer\Exception;

hat gefehlt.

Jetzt zickt der PHPMailer noch, weil 1&1 / IONISOS nur noch SMTP mit SSL unterstützt…

Bei mir sieht das sowohl im IPS Editor und auch im Forums-Editor übrigens immer folgendermaßen aus:

Bildschirmfoto 2023-12-18 um 18.05.43

Warum das dann in der Darstellung drei Punkte werden, keine Ahnung!

Jetzt klappt es mit hinzufügen dieser Zeile:

$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;

Nochmals vielen Dank!!!

Dann hilf doch nun bitte den am Thema interessierten Mitlesern mit einer kurzen Zusammenfassung:

  • Welche Files wohin kopiert
  • Code des Scripts (unter Verwendung des Code-Tags)

So schaut es im Forum aus… Und das kann man nicht kopieren und ist kein gültiges PHP.
image

Darum der Hinweis von @volkerm und mir bitte mit

Vorformatierter Text zu Arbeiten
Dann sind " auch "

und nicht „so“
Michael

Hier nochmal eine kurze Zusammenfassung: Ich hatte bisher zum versenden von E-Mails mit mehr als einem Attachment den PHPMail von hier PHPMailer download | SourceForge.net genutzt, der allerdings seit 2010 nicht mehr weiterentwickelt wird.

Mit PHP Version 8 funktioniert der aber nicht mehr und ich bin jetzt umgestiegen auf den PHPMailer unter Github https://github.com/PHPMailer/PHPMailer/tree/master/src.

Zur Installation unter IPS habe ich im IPS Ordner unter Scripts in einem neuen Unterverzeichnis PHPMailer die folgenden Dateien vom Github Projekt (Link siehe oben) gespeichert.

Bildschirmfoto 2023-12-19 um 17.08.16

Der entsprechende Code zur Nutzung sieht wie folgt aus, wobei das bei mir mit einer E-Mail von IONOS läuft.

    //Import the PHPMailer class into the global namespace
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;

    require("./PHPMailer/PHPMailer.php");
    require("./PHPMailer/SMTP.php");
    require("./PHPMailer/Exception.php");

    // KONFIGURATION VON KONSTANTEN
    include ("27397.ips.php"); 

        try {

            $mail = new PHPMailer();
            $mail->isSMTP();
            $mail->SMTPDebug = SMTP::DEBUG_OFF;
            $mail->Host = 'smtp.xyz.de';
            $mail->Port = 465;
            $mail->SMTPAuth = true;
            $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
            $mail->Username = 'a@b.de';
            $mail->Password = 'xyz';
            $mail->setFrom('a@b.de', 'XYZ INFO');
            $mail->addReplyTo('a@b.de', 'XYZ INFO');
            $mail->addAddress('a@b.de', 'XYZ INFO');
            $mail->Subject = 'XYZ INFO MAIL';
            $mail->msgHTML('E-Mail Text gif. in HTML formatiert');
            // CAMS_HOME_DIR in KONFIGURATION definiert
            $mail->addAttachment(CAMS_HOME_DIR . '01234.jpg');
            $mail->addAttachment(CAMS_HOME_DIR . '12345.jpg');

            if (!$mail->send()) {
                echo 'Mailer Error: ' . $mail->ErrorInfo;
            } else {
                echo 'Message sent!';
            }

        } catch (Exception $e) {
            echo $e->errorMessage(); 
        } catch (\Exception $e) { 
            echo $e->getMessage(); 
        }

    }

4 „Gefällt mir“