-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendmail.php
More file actions
63 lines (51 loc) · 1.97 KB
/
sendmail.php
File metadata and controls
63 lines (51 loc) · 1.97 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
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;
use PHPMailer\PHPMailer\SMTP;
// Include Composer autoload.php file
require 'vendor/autoload.php';
// Create object of PHPMailer class
$mail = new PHPMailer(true);
$output = '';
if (isset($_POST['send'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = "it@mcindeez.com";
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Email ID from which you want to send the email
$mail->setFrom('it@mcindeez.com');
// Recipient Email ID where you want to receive emails
$mail->addAddress('it@mcindeez.com');
$mail->isHTML(true);
$mail->Subject = 'Form Submission';
if ($other)
{
$mail->Body = "<h3>Name : $name <br>Email : $email <br>Phone: $phone <br> Subject: $other <br>Message : $message</h3>";
}
else {
$mail->Body = "<h3>Name : $name <br>Email : $email <br>Phone: $phone <br> Subject: $subject <br>Message : $message</h3>";
}
if (isset($_FILES['uploaded_file'])
&& $_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK
) {
$mail->addAttachment($_FILES['uploaded_file']['tmp_name'],
$_FILES['uploaded_file']['name']);
}
$mail->send();
echo '<script>window.location.href = "./response.html";</script>';
$output = '<div class="alert alert-success"><h5>Thankyou! for contacting us, We\'ll get back to you soon!</h5></div>';
}
catch (Exception $e) {
echo '<script>window.location.href = "./error.html";</script>';
$output = '<div class="alert alert-danger"><h5>' . $e->getMessage() . '</h5></div>';
}
}
?>