Ankündigung

Einklappen
Keine Ankündigung bisher.

PHPMailer anwenden

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • PHPMailer anwenden

    Hallo,
    mir wurde in diesem Forum empfohlen eine Mailerklasse für den E-Mail-Versand zu nutzen. Dazu gab es zwei hilfreiche Links:
    https://php-de.github.io/jumpto/mail-class/

    http://www.php-rocks.de/thema/51-htm...phpmailer.html
    Nun probiere ich schon seit Wochen mit den Anleitungen herum, aber ich bekomme keinen der beiden Mailer zum Laufen. Das fängt schon damit an, dass die im Beitrag angegebene Datei PHPMailerAutoload.php:
    include_once 'phpmailer/PHPMailerAutoload.php';
    in der aktuellen Version6.0 der PHPMailers nicht mehr vorhanden ist (habe sie auf jeden Fall nicht gefunden). Und auch alle anderen Versuche den Mailer mit den vorhandenen Dateien einzubinden, hat nicht geklappt. Hat von Euch schon jemand erfolgreich die Version 6.0 eingebunden?
    Viele Grüße Jani

  • #2
    Hast du dich an die Anleitung von Github gehalten? - Ich persönlich bevorzuge Swiftmailer.

    PHP-Code:
      <?php
    // Import PHPMailer classes into the global namespace
    // These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use 
    PHPMailer\PHPMailer\Exception;

    //Load composer's autoloader
    require 'vendor/autoload.php';

    $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
    try {
        
    //Server settings
        
    $mail->SMTPDebug 2;                                 // Enable verbose debug output
        
    $mail->isSMTP();                                      // Set mailer to use SMTP
        
    $mail->Host 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
        
    $mail->SMTPAuth true;                               // Enable SMTP authentication
        
    $mail->Username 'user@example.com';                 // SMTP username
        
    $mail->Password 'secret';                           // SMTP password
        
    $mail->SMTPSecure 'tls';                            // Enable TLS encryption, `ssl` also accepted
        
    $mail->Port 587;                                    // TCP port to connect to

        //Recipients
        
    $mail->setFrom('from@example.com''Mailer');
        
    $mail->addAddress('joe@example.net''Joe User');     // Add a recipient
        
    $mail->addAddress('ellen@example.com');               // Name is optional
        
    $mail->addReplyTo('info@example.com''Information');
        
    $mail->addCC('cc@example.com');
        
    $mail->addBCC('bcc@example.com');

        
    //Attachments
        
    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
        
    $mail->addAttachment('/tmp/image.jpg''new.jpg');    // Optional name

        //Content
        
    $mail->isHTML(true);                                  // Set email format to HTML
        
    $mail->Subject 'Here is the subject';
        
    $mail->Body    'This is the HTML message body <b>in bold!</b>';
        
    $mail->AltBody 'This is the body in plain text for non-HTML mail clients';

        
    $mail->send();
        echo 
    'Message has been sent';
    } catch (
    Exception $e) {
        echo 
    'Message could not be sent. Mailer Error: '$mail->ErrorInfo;
    }
    ?>

    Kommentar


    • #3
      Hallo,

      Die Anpassungen zur aktuellen Version werde ich heute im Tutorial aktualisieren.
      Das Beispiel, das chim Dir aus Github nochmal gezeigt hat, funktioniert nur, wenn Du composer verwendest.

      Kommentar


      • #4
        Hallo,
        ich verwende keinen composer. Ich werde dann mal das neue Tutorial abwarten. Was ist an dem Swiftmailer besser?
        Jani

        Kommentar


        • #5
          Öhm... hast du die Anleitung dort schon gelesen?

          Alternatively, if you're not using composer, ...
          https://github.com/PHPMailer/PHPMail...ation--loading

          Kommentar


          • #6
            Habe selbst noch nicht mit der 6er Version gearbeitet. Dies hier aus der Readme schon probiert?


            Alternatively, if you're not using composer, copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:
            PHP-Code:
            <?php
            use PHPMailer\PHPMailer\PHPMailer;
            use 
            PHPMailer\PHPMailer\Exception;

            require 
            'path/to/PHPMailer/src/Exception.php';
            require 
            'path/to/PHPMailer/src/PHPMailer.php';
            require 
            'path/to/PHPMailer/src/SMTP.php';
            If you're not using the SMTP class explicitly (you're probably not), you don't need a use line for the SMTP class.

            Kommentar


            • #7
              Zitat von Jani Beitrag anzeigen
              Hallo,
              Was ist an dem Swiftmailer besser?
              Nichts, ist halt nur ein anderes Script,, letztendlich machen beide Scripte das gleiche.

              hast du das gemacht was in der Anleitung steht

              <?php
              require 'PHPMailerAutoload.php';
              $mail = new PHPMailer;


              Save it as a PHP document in the same directory where you've saved class.phpmailer.php. If no errors result from running the script, your installation has been done correctly.

              Kommentar


              • #8
                Ja, habe ich alles schon probiert (soweit ich das verstanden habe in der englischen readme Anleitung), führt aber immer nur zu Fehlermeldungen wie dieser:

                Fatal error: Class 'PHPMailer' not found oder Failed opening required 'phpmailer/PHPMailerAutoload.php

                Jani


                Kommentar


                • #9
                  hast du denn die Datei phpmailer.php im selben Verzeichnis wie das Script welches die Datei aufruft.
                  Das solltest du prüfen, wir können das nicht aus der Ferne.

                  Kommentar


                  • #10
                    Und hast du die Meldungen dann auch geprüft, nachvollzogen? Da wurde die Datei wohl nicht an der Stelle gefunden. Prüf das mal.

                    Kommentar


                    • #11
                      Hm, meine DateI „mailer.php“ liegt im Ordner „php7“ dort liegt auch der Ordner „PHPMailer“ mit dem Unterordner „src“ und in diesem die Datei „PHPMailer.php“. Müsste doch eigentlich stimmen. Und trotzdem kommt die Fehlermeldung:
                      Warning: require(path/to/PHPMailer/src/Exception.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in C:\xampp\htdocs\Inetpub\kontaktformular\php7\maile r.php on line 6

                      Kommentar


                      • #12
                        Code:
                        C:\xampp\htdocs\Inetpub\kontaktformular\php7\maile r.php on line 6
                        Ist das ein Leerzeichen im Dateiname?

                        Und den require solltest du immer mit __DIR__ angeben. Siehe Link in meiner Signatur.

                        Kommentar


                        • #13
                          Naja, dann wird der Pfad nicht stimmen. Was erwartest du jetzt vom Forum? Das man auf deinem Rechner nachschaut wie der richtige Pfad lautet?

                          Kommentar


                          • #14
                            use PHPMailer\PHPMailer\PHPMailer
                            Oh je, was soll das denn?

                            Kommentar


                            • #15
                              Wenn du mit der Pfadfindung etc, nicht so vetraut bist, wobei der Fehlermeldung mal nachzugehen jetzt nicht all zu schwer sein sollte, probier es doch einfach mal mit Composer.

                              Kommentar

                              Lädt...
                              X