-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmailsend.php
executable file
·119 lines (102 loc) · 3.86 KB
/
mailsend.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/*************************************************************
* THE ADDRESS BOOK : version 1.04d
*
*
*
****************************************************************
*
* mailsend.php
* Delivery service for mailto.php
* Originally written by Joe Chen
*
*************************************************************/
// ** GET CONFIGURATION DATA **
require_once('constants.inc');
require_once(FILE_FUNCTIONS);
require_once(FILE_LIB_MAIL);
require_once(FILE_CLASS_OPTIONS);
// ** START SESSION **
session_start();
// ** OPEN CONNECTION TO THE DATABASE **
$db_link = openDatabase($db_hostname, $db_username, $db_password, $db_name);
// ** RETRIEVE OPTIONS THAT PERTAIN TO THIS PAGE **
$options = new Options();
// ** CHECK FOR LOGIN **
// list($userGroup, $userHomeName, $userHomePage, $userCapabilities) = checkForLogin($address_session_name, CAP_USER);
checkForLogin('admin','user');
// ** GET SOME INFORMATION **
if(empty($_POST['mail_from'])) {
reportScriptError($lang['ERR_MAIL_NO_SENDER']);
}
// ** COMPOSE THE MAIL **
$mail = new PHPMailer();
$mail->SetLanguage(LANGUAGE_CODE, "lib/phpmailer/language/");
// $mail->IsSMTP(); // set mailer to use SMTP
// $mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
// $mail->SMTPAuth = true; // turn on SMTP authentication
// $mail->Username = "jswan"; // SMTP username
// $mail->Password = "secret"; // SMTP password
$mail->From = $_POST['mail_from'];
$mail->FromName = $_POST['mail_from_name'];
// GET EMAIL ADDRESSES
// There are two ways that mailto.php can send e-mail addresses, based on the two ways
// of sending. The first is the mailing list and addresses are stored in $_POST['mail_to']
// as an array. The second method allows the user to write in e-mail addresses and they will
// be stored in $_POST['mail_to'] as a string. In the event that it is a string (with
// commas separating each address) we must break up that string into an array.
// Note: We can split on commas only. any resulting whitespace is trimmed automatically by PHPMailer.
$mail->ClearAddresses();
$mailto = $_POST['mail_to'];
if (is_string($mailto)) {
$mailto = explode(",", $mailto);
}
for ($a=0; $a < count($mailto); $a++) {
// $mail->AddAddress("[email protected]", "Josh Adams"); // set names is possible? maybe done later
$mail->AddAddress($mailto[$a]);
}
$mail->WordWrap = 50;
$mail->CharSet = $lang['CHARSET'];
$mail->Subject = stripslashes($_POST['mail_subject']);
$mail->Body = stripslashes($_POST['mail_body']);
$mail->ClearCCs();
$mail->ClearBCCs();
$mail->AddCC($_POST['mail_cc']) ; // To get CC to work, Howe had to modify class.phpmailer.php at around line 780
$mail->AddBCC($_POST['mail_bcc']) ;
// ** SEND! **
if (!$mail->Send()) {
reportScriptError($lang['ERR_MAIL_NOT_SENT'] . $mail->ErrorInfo);
}
?>
<html>
<head>
<title><?php echo $lang[TAB]. ' - '. $lang[MSG_MAIL_SENT_TITLE]?></title>
<link rel="stylesheet" href="styles.css" type="text/css">
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
<meta http-equiv="PRAGMA" content="NO-CACHE">
<meta http-equiv="EXPIRES" content="-1">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['CHARSET']?>"
</head>
<body>
<p>
<?php
echo"
<h3>". $lang[MSG_MAIL_SENT]."</h3>
<h4>". $lang[MAIL_SUBJ]. ": ".$mail->Subject . "</h4>
<h4>TO: ";
reset($mailto);
for ($a=0; $a < count($mailto); $a++) {
echo $mailto[$a]. "<br> ";
}
echo "</h4>";
if($_POST['mail_cc']){
echo "<h4>CC: ". $_POST['mail_cc']."</h4>";
}
if($_POST['mail_bcc']){
echo "<h4>BCC: ". $_POST['mail_bcc']."</h4><p>";
}
echo "<h4>". $lang[MAIL_MSG].": </h4><br>
<div class=\"error\">". $mail->Body."</div>
<br><br><center><b><a href=\"".FILE_LIST."\">$lang[BTN_LIST]</a></b></center>"; ?>
</body>
</html>