Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //PHPMailer page: https://github.com/PHPMailer/PHPMailer
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'PHPMailer/src/Exception.php';
- require 'PHPMailer/src/PHPMailer.php';
- require 'PHPMailer/src/SMTP.php';
- $mail = new PHPMailer(true); //Passing 'true' enables exceptions
- try {
- $mail->CharSet = 'UTF-8';
- $mail->SMTPDebug = 2; //0 1 2 3 4
- $mail->isSMTP();
- $mail->Host = 'mail.example.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'user@example.com';
- $mail->Password = 'password';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->setFrom('user@example.com', 'Mailer');
- $mail->addAddress('user2@example.com', 'Example User');
- $mail->addReplyTo('info@example.com', 'Information');
- $mail->isHTML(true);
- $mail->Subject = 'Testas iš PHPMailer.';
- $mail->Body = 'Testas iš PHPMailer. Tikriname ar veikia paštas.';
- $mail->AltBody = 'Testas is PHPMailer. Tikriname ar veikia pastas.';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement