Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Import PHPMailer classes into the global namespace
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require_once 'vendor/autoload.php';
- $mail = new PHPMailer(true);
- try {
- //$mail->isSMTP();
- $mail->Host = 'smtp.googlemail.com'; //gmail SMTP server
- $mail->SMTPAuth = true;
- $mail->Username = ‘email@gmail.com'; //username
- $mail->Password = ‘password’; //password
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465; //smtp port
- $mail->setFrom('noreply@artisansweb.net', 'Artisans Web');
- //Set who the message is to be sent to
- $mail->addAddress(‘user@gmail.com', 'User Name');
- $mail->isHTML(true);
- $mail->Subject = 'Email Subject';
- $mail->Body = 'Email Body';
- if (!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement