-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmailconfig.php
39 lines (32 loc) · 982 Bytes
/
mailconfig.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
36
37
38
39
<?php
use PHPMailer\PHPMailer\PHPMailer;
if (isset($_POST['name']) && isset($_POST['email'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
require_once "phpmailer/PHPMailer.php";
require_once "phpmailer/SMTP.php";
require_once "phpmailer/Exception.php";
$mail = new PHPMailer();
// SMTP Settings
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = $senderemail;
$mail->Password = $senderpassword;
$mail->Port = 465; //587
$mail->SMTPSecure = "ssl"; //tls
//Email Settings
$mail->isHTML(true);
$mail->setFrom($email, $name);
$mail->addAddress($email);
$mail->Subject = $subject;
$mail->Body = $message;
if ($mail->send()) {
echo "Email sent successfully to " . $email;
} else {
echo "ERRORRRR: <br><br>" . $mail->ErrorInfo;
}
}