Skip to content

PHPMailer

Verschoben PHP
  • Installation

    Wenn man mit PHP Mails verschicken will, stößt man sehr oft auf die Empfehlung PHPMailer. Das scheint wohl die Maillösung für PHP zu sein. Ok, dann mal testen. Erste Schwierigkeit, wie downloaden? Da stößt man auf composer, das mal ausprobiert. Aber ehrlich gesagt, verstehe ich das nicht so wirklich....

    composer require phpmailer/phpmailer
    

    Wegen Ahnungslosigkeit, habe ich dann das entsprechende Verzeichnis kopiert. Gut, das haben wir jetzt erst mal.

    Test-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;
     
     
     require __DIR__ . '../../vendor/phpmailer/phpmailer/src/Exception.php';
     require __DIR__ . '../../vendor/phpmailer/phpmailer/src/PHPMailer.php';
     require __DIR__ . '../../vendor/phpmailer/phpmailer/src/SMTP.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 = 'xxxx.de;xxxxx.de';  // Specify main and backup SMTP servers
         $mail->SMTPAuth = true;                               // Enable SMTP authentication
         $mail->Username = 'USER';                 // SMTP username
         $mail->Password = 'PASSWORD';                           // SMTP password
         $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
         $mail->Port = 587;                                    // TCP port to connect to
     
         //Recipients
         $mail->CharSet = 'utf-8'; 
         $mail->setFrom('webmaster@domain.de', 'Domain_Name');
         $mail->addAddress('EMail_Addresse', 'Name');     // Add a recipient
         //$mail->addAddress('test@example.com');               // Name is optional
         $mail->addReplyTo('webmaster@domain.de', 'Name');
         //$mail->addCC('cc@example.com');
         //$mail->addBCC('bcc@example.com');
     
         //Attachments
         $mail->addAttachment('test.jpg');         // Add attachments
         //$mail->addAttachment('test.jpg', 'test.jpg');    // Optional name
     
         //Content
         $mail->isHTML(true);                                  // Set email format to HTML
         $mail->Subject = 'Testmail';
         $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;
     }
    

    Deutsche Umlaute

    Hatte ich erst nach Einfügen von

    $mail->CharSet = 'utf-8';
    

  • PHP - ChatGPT

    PHP
    1
    0 Stimmen
    1 Beiträge
    73 Aufrufe
    Niemand hat geantwortet
  • PHP Webseite lokal einhängen mit sshfs

    PHP
    1
    0 Stimmen
    1 Beiträge
    40 Aufrufe
    Niemand hat geantwortet
  • Anhänge mit dem PHPMailer

    PHP
    3
    1 Stimmen
    3 Beiträge
    139 Aufrufe
    FrankMF

    @bofh73 Prima, das Du das Problem selber lösen konntest. Prima ist immer ein kleiner Codeschnipsel, damit auch andere Leser was von deinen Beiträgen haben.

  • PHP Data Objects

    Linux
    4
    0 Stimmen
    4 Beiträge
    279 Aufrufe
    FrankMF
    Datensatz löschen

    Voraussetzung ist, das man die ID des zu löschenden Eintrages kennt.

    $statement = $pdo->prepare("DELETE FROM feinstaub WHERE id = ?"); $statement->execute(array($id)); if ($statement->execute()) { echo "Der DB-Eintrag wurde erfolgreich gelöscht!"; } else { echo "Bitte den Administrator informieren!"; }
  • Wichtige Info

    Angeheftet PHP
    1
    0 Stimmen
    1 Beiträge
    199 Aufrufe
    Niemand hat geantwortet
  • Geo Loacation

    PHP
    1
    0 Stimmen
    1 Beiträge
    289 Aufrufe
    Niemand hat geantwortet
  • Reload einer PHP Seite verhindern

    PHP
    1
    0 Stimmen
    1 Beiträge
    694 Aufrufe
    Niemand hat geantwortet
  • PHP Exif Daten aus Bild auslesen

    Verschoben PHP
    1
    0 Stimmen
    1 Beiträge
    466 Aufrufe
    Niemand hat geantwortet