SHOW:
|
|
- or go back to the newest paste.
1 | <!DOCTYPE html> | |
2 | <html> | |
3 | <head> | |
4 | <title>Test</title> | |
5 | </head> | |
6 | <body> | |
7 | - | require("phpmailer/_lib/class.phpmailer.php"); |
7 | + | |
8 | - | $mail = new PHPMailer(true); |
8 | + | |
9 | - | $mail->isSMTP(); // Set mailer to use SMTP |
9 | + | try { |
10 | - | $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers |
10 | + | require_once('phpmailer/_lib/class.phpmailer.php'); |
11 | - | $mail->SMTPAuth = true; // Enable SMTP authentication |
11 | + | require_once('phpmailer/_lib/class.smtp.php'); // vielleicht auch ohne |
12 | - | $mail->Username = 'user@gmail.com'; // SMTP username |
12 | + | |
13 | - | $mail->Password = 'password'; // SMTP password |
13 | + | |
14 | - | $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted |
14 | + | $mail = new PHPMailer(true); |
15 | - | $mail->Port = 587; // TCP port to connect to |
15 | + | $mail->isSMTP(); // Set mailer to use SMTP |
16 | $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers | |
17 | - | $mail->setFrom('user@gmail.com', 'Mailer'); |
17 | + | $mail->SMTPAuth = true; // Enable SMTP authentication |
18 | - | $mail->addAddress('empfänger@gmail.com', 'Empfänger'); // Add a recipient |
18 | + | $mail->Username = 'user@gmail.com'; // SMTP username |
19 | - | $mail->addReplyTo('user@gmail.com', 'Information'); |
19 | + | $mail->Password = 'password'; // SMTP password |
20 | $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted | |
21 | - | $mail->isHTML(true); // Set email format to HTML |
21 | + | $mail->Port = 587; // TCP port to connect to |
22 | ||
23 | - | $mail->Subject = 'Here is the subject'; |
23 | + | $mail->setFrom('user@gmail.com', 'Mailer'); |
24 | - | $mail->Body = 'This is the HTML message body <b>in bold!</b>'; |
24 | + | $mail->addAddress('empfänger@gmail.com', 'Empfänger'); // Add a recipient |
25 | - | $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; |
25 | + | $mail->addReplyTo('user@gmail.com', 'Information'); |
26 | - | try{ |
26 | + | |
27 | $mail->isHTML(true); // Set email format to HTML | |
28 | - | echo 'Message has been sent'; |
28 | + | |
29 | $mail->Subject = 'Here is the subject'; | |
30 | - | catch{ |
30 | + | $mail->Body = 'This is the HTML message body <b>in bold!</b>'; |
31 | - | echo 'Message could not be sent.'; |
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> |