forked from rmdort/ecard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
send-email.php
104 lines (66 loc) · 2.52 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
require("phpmailer/class.phpmailer.php");
// DB Connect
include("db.php");
// Post Variable
$FacebookUID = $_POST['FacebookUID'];
$FacebookUsername = $_POST['FacebookUsername'];
$FacebookEmail = $_POST['FacebookEmail'];
$CardID = $_POST['CardID'];
$ImageURL = $_POST['ImageURL'];
$Message = $_POST['Message'];
$RecipientEmails = $_POST['RecipientEmails'];
$recipientID = $_POST['recipientID'];
$NoFacebookEmail = $_POST['NoFacebookEmail'];
$NoFacebookName = $_POST['NoFacebookName'];
// Common Variables
$emailsubject = "This is a sample subject!"; // Subject
// Send EDM if the Facebook UID is Empty
if ($FacebookUID == null){
$FacebookUID =0;
//Add to Database
$query = "INSERT INTO emails (UID,CardID,SendersName,SendersEmail,RecipientEmail,Message,Image,recipientID) VALUES ('$FacebookUID', '$CardID', '$NoFacebookName', '$NoFacebookEmail', '$RecipientEmails[0]', '$Message', '$ImageURL','')";
mysql_query($query) or die(mysql_error());
mysql_close($conn);
// Email Recipient
$emailsubject = "This is a sample subject!";
$emailbody = file_get_contents("edm.html");
$mail = new PHPMailer();
$mail->Mailer = "smtp";
$mail->Port = 465;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPKeepAlive = true;
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = ""; // SMTP password
$webmaster_email = "[email protected]"; //Reply to this email ID
$mail->AddReplyTo($webmaster_email,"Webmaster"); // Reply To
$mail->From = $webmaster_email;
$mail->FromName = "Germs Ecard Emailer";
$email=preg_split("/[,]+/",$RecipientEmails[0]); // Recipients Email Split by Comma
// Only Find the first email as Non facebook user can only send to 1 friend
$email=$email[0];
$name="name"; // Recipient's name
$mail->AddAddress($email,$name);
$mail->Subject = $emailsubject;
$mail->IsHTML(true);
$mail->Body = file_get_contents("edm.html");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
}
// Else Send Facebook Email to Inbox
else {
//Add to Database
$query = "INSERT INTO emails (UID,CardID,SendersName,SendersEmail,RecipientEmail,Message,Image,recipientID) VALUES ('$FacebookUID', '$CardID', '$NoFacebookName', '$NoFacebookEmail', '$RecipientEmails[0]', '$Message', '$ImageURL','$recipientID[0]')";
mysql_query($query) or die(mysql_error());
mysql_close($conn);
}
?>