Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Test</title>
  5. </head>
  6. <body>
  7. <?php  
  8.  
  9. try {
  10.     require_once('phpmailer/_lib/class.phpmailer.php');  
  11.     require_once('phpmailer/_lib/class.smtp.php'); // vielleicht auch ohne
  12.  
  13.  
  14.     $mail = new PHPMailer(true);
  15.     $mail->isSMTP();                                      // Set mailer to use SMTP
  16.     $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  17.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  18.     $mail->Username = 'user@gmail.com';                 // SMTP username
  19.     $mail->Password = 'password';                           // SMTP password
  20.     $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  21.     $mail->Port = 587;                                    // TCP port to connect to
  22.  
  23.     $mail->setFrom('user@gmail.com', 'Mailer');
  24.     $mail->addAddress('empfänger@gmail.com', 'Empfänger');     // Add a recipient
  25.     $mail->addReplyTo('user@gmail.com', 'Information');
  26.  
  27.     $mail->isHTML(true);                                  // Set email format to HTML
  28.  
  29.     $mail->Subject = 'Here is the subject';
  30.     $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  31.     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  32.     $mail->send();
  33. } catch(phpmailerException $e) {
  34.     echo $e->errorMessage();
  35. } catch(Exception $e) {
  36.     echo $e->getMessage();
  37. }
  38.  
  39. ?>  
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement