-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.php
35 lines (28 loc) · 934 Bytes
/
sendmail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
session_start();
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);
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]"; // enter your own email address
$mail->Password = "your-own-app-password"; // enter your own app password
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
if (isset($_POST['submit'])) {
$mail->setFrom('[email protected]');
$mail->addAddress($_POST['email']);
$mail->isHTML(true);
$mail->Subject = $_POST['subject'];
$mail->Body = $_POST['body'];
$mail->send();
$_SESSION['status'] = "email sent successfully";
$_SESSION['email'] = $_POST['email'];
} else {
$_SESSION['status'] = "Please try again";
}
header("location:index.php");