-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
45 lines (31 loc) · 1.14 KB
/
send.php
File metadata and controls
45 lines (31 loc) · 1.14 KB
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
if(isset($_POST['send'])){
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
try{
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// sender's gmail account
$mail->Username = "middleman415@gmail.com";
$mail->Password = "uyeo fwtb gykj kqch";
$mail->setFrom("middleman415@gmail.com", "User Contact");
$mail->addReplyTo($email, $name);
// receiver's gmail account
$mail->addAddress("justcode301@gmail.com");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
echo "Email sent successfully";
} catch(Exception $e){
echo "Mailer Error: {$mail->ErrorInfo}";
}
}