-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.php
41 lines (35 loc) · 1.41 KB
/
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
<?php
// Get client IP address (honor X-Forwarded-For)
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
// Send Email
if (strpos($_SERVER['HTTP_REFERER'], 'gamily.in') !== false || strpos($_SERVER['HTTP_REFERER'], '127.0.0.1') !== false ) {
require '../PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = 'research.iiit.ac.in';
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Username = '[email protected]';
$mail->Password = 'WHY YOU THINK I SHOULD SHARE THIS?';
$mail->From = $_POST['email'];
$mail->FromName = $_POST['name'];
$mail->AddAddress('[email protected]', 'Shivam Khandelwal');
$mail->AddCC('[email protected]', 'Saikrishna Sripada');
$mail->IsHTML(true);
$mail->Subject = 'Gamily.in contact form : ' . $_POST['subject'];
$mail->Body = nl2br($_POST['message']) . '<br><br>Sent from IP : ' . $ip;
if(!$mail->Send())
{
echo 'Error. Please send to [email protected] directly. Sorry. :(';
exit(0);
}
echo 'Thanks for writing to us. We will try to get back asap!';
}