-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend_email.php
63 lines (47 loc) · 1.89 KB
/
send_email.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'sendemail/vendor/PHPMailer/src/Exception.php';
require 'sendemail/vendor/PHPMailer/src/PHPMailer.php';
require 'sendemail/vendor/PHPMailer/src/SMTP.php';
session_start();
if(isset($_POST['send'])){
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
//Load composer's autoloader
$mail = new PHPMailer(true);
try {
//Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'G_arena05';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
//Send Email
$mail->setFrom('[email protected]');
//Recipients
$mail->addAddress($email);
$mail->addReplyTo('[email protected]');
//Content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
$_SESSION['result'] = 'Message has been sent';
$_SESSION['status'] = 'ok';
} catch (Exception $e) {
$_SESSION['result'] = 'Message could not be sent. Mailer Error: '.$mail->ErrorInfo;
$_SESSION['status'] = 'error';
}
header("location: user_contactus.php");
}