Klanten krijgen rare mails
Beste winkelhouder, klant.
Eindelijk werkt http://www.dvcgraphics.com terug.
Wie wil kan even een kijkje nemen.
De nieuwe openingsuren zijn:
Maandag en dinsdag van 10u doorlopend tot 18u
Donderdag en vrijdag van 10u doorlopend tot 18u
Woensdag en zaterdag van 14u tot 17u.
Mvg Didier & Stefanie.
Ik stuurde ook naar mijn mail dit bericht en kreeg:
Beste winkelhouder, klant.\\r\\n\\r\\nEindelijk werkt http://www.dvcgraphics.com terug.\\r\\nWie wil kan even een kijkje nemen.\\r\\n\\r\\nDe nieuwe openingsuren zijn:\\r\\nMaandag en dinsdag van 10u doorlopend tot 18u\\r\\nDonderdag en vrijdag van 10u doorlopend tot 18u\\r\\nWoensdag en zaterdag van 14u tot 17u.\\r\\n\\r\\nMvg Didier & Stefanie.\\r\\n
Hoe zou dat komen, is dit op te lossen?
/r is een Windows nieuwe regel en /n Linux.
De oorzaak wete ik niet excact maar daar ergens zal het probleem liggen.
Kun je misschien wat code laten zien van het versturen van de mail?
Ik wil dat doen hoor maar ik weet niet welk bestand dit zou moeten zijn die dat doet.
Trouwens is er een groot stuk zend encrypted...
Misschien nu de site weer werkt ik kan vragen hoe ik die site zonden encryptie kan laten draaien.
Nu hij weer werkt wil ik er niet teveel meer mee klooien ;-)
Nu ja, zou wel leuk zijn dat mijn klanten normaal leesbare mails krijgt.
Ik zoek eens de template file en zal het hier plakken.
Ik geloof dat het al voor een groot gedeelte al een open-source script (OScommerce) was, dus zou het dan wel meevallen.
Zet ze eens tussen dubbele quotes.
Dus '\n\r' wordt "\n\r",
@SanThe dat zou het (deels) kunnen verklaren. Ook kan de plaintext text verstuurd zijn als HTML, en wordt in het script hier ook "addslashes" overheen gekieperd als extra "beveiliging".
Ik heb met iDezender PRO 8.1 al 1 php bestand mooi kunnen de-scripten.
Moet ik dat nu met alle bestanden doen, is uploaden genoeg dan? (zal die voor de veiligheid originelenaam-dezend.php geven als naam bvb.
ALs ik dat met alle gecrypte bestanden doen is dit dan genoeg?
Toevoeging op 16/02/2015 22:58:10:
Ik denk dat ik het gevonden heb, hier de newsletter.php
Code (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/*
$Id: product_notification.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 osCommerce
Released under the GNU General Public License
*/
class product_notification {
var $show_choose_audience, $title, $content;
function product_notification($title, $content) {
$this->show_choose_audience = true;
$this->title = $title;
$this->content = $content;
}
function choose_audience() {
global $HTTP_GET_VARS, $languages_id;
$products_array = array();
$products_query = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . $languages_id . "' and pd.products_id = p.products_id and p.products_status = '1' order by pd.products_name");
while ($products = tep_db_fetch_array($products_query)) {
$products_array[] = array('id' => $products['products_id'],
'text' => $products['products_name']);
}
$choose_audience_string = '<script language="javascript"><!--
function mover(move) {
if (move == \'remove\') {
for (x=0; x<(document.notifications.products.length); x++) {
if (document.notifications.products.options[x].selected) {
with(document.notifications.elements[\'chosen[]\']) {
options[options.length] = new Option(document.notifications.products.options[x].text,document.notifications.products.options[x].value);
}
document.notifications.products.options[x] = null;
x = -1;
}
}
}
if (move == \'add\') {
for (x=0; x<(document.notifications.elements[\'chosen[]\'].length); x++) {
if (document.notifications.elements[\'chosen[]\'].options[x].selected) {
with(document.notifications.products) {
options[options.length] = new Option(document.notifications.elements[\'chosen[]\'].options[x].text,document.notifications.elements[\'chosen[]\'].options[x].value);
}
document.notifications.elements[\'chosen[]\'].options[x] = null;
x = -1;
}
}
}
return true;
}
function selectAll(FormName, SelectBox) {
temp = "document." + FormName + ".elements[\'" + SelectBox + "\']";
Source = eval(temp);
for (x=0; x<(Source.length); x++) {
Source.options[x].selected = "true";
}
if (x<1) {
alert(\'' . JS_PLEASE_SELECT_PRODUCTS . '\');
return false;
} else {
return true;
}
}
//--></script>';
$global_button = '<script language="javascript"><!--' . "\n" .
'document.write(\'<input type="button" value="' . BUTTON_GLOBAL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '\\\'">\');' . "\n" .
'//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '">[ ' . BUTTON_GLOBAL . ' ]</a></noscript>';
$cancel_button = '<script language="javascript"><!--' . "\n" .
'document.write(\'<input type="button" value="' . BUTTON_CANCEL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '\\\'">\');' . "\n" .
'//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">[ ' . BUTTON_CANCEL . ' ]</a></noscript>';
$choose_audience_string .= '<form name="notifications" action="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm') . '" method="post" onSubmit="return selectAll(\'notifications\', \'chosen[]\')"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td align="center" class="main"><b>' . TEXT_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('products', $products_array, '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
' <td align="center" class="main"> <br>' . $global_button . '<br><br><br><input type="button" value="' . BUTTON_SELECT . '" style="width: 8em;" onClick="mover(\'remove\');"><br><br><input type="button" value="' . BUTTON_UNSELECT . '" style="width: 8em;" onClick="mover(\'add\');"><br><br><br><input type="submit" value="' . BUTTON_SUBMIT . '" style="width: 8em;"><br><br>' . $cancel_button . '</td>' . "\n" .
' <td align="center" class="main"><b>' . TEXT_SELECTED_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('chosen[]', array(), '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
' </tr>' . "\n" .
'</table></form>';
return $choose_audience_string;
}
function confirm() {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$audience = array();
if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
$products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS);
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = '1';
}
$customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_info_id']] = '1';
}
} else {
$chosen = $HTTP_POST_VARS['chosen'];
$ids = implode(',', $chosen);
$products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id in (" . $ids . ")");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = '1';
}
$customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_info_id']] = '1';
}
}
$confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, sizeof($audience)) . '</b></font></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><b>' . $this->title . '</b></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . tep_draw_form('confirm', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . "\n" .
' <td align="right">';
if (sizeof($audience) > 0) {
if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
$confirm_string .= tep_draw_hidden_field('global', 'true');
} else {
for ($i = 0, $n = sizeof($chosen); $i < $n; $i++) {
$confirm_string .= tep_draw_hidden_field('chosen[]', $chosen[$i]);
}
}
$confirm_string .= tep_image_submit('button_send.gif', IMAGE_SEND) . ' ';
}
$confirm_string .= '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=send') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "\n" .
' </tr>' . "\n" .
'</table>';
return $confirm_string;
}
function send($newsletter_id) {
global $HTTP_POST_VARS;
$audience = array();
if (isset($HTTP_POST_VARS['global']) && ($HTTP_POST_VARS['global'] == 'true')) {
$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
'lastname' => $products['customers_lastname'],
'email_address' => $products['customers_email_address']);
}
$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
'lastname' => $customers['customers_lastname'],
'email_address' => $customers['customers_email_address']);
}
} else {
$chosen = $HTTP_POST_VARS['chosen'];
$ids = implode(',', $chosen);
$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in (" . $ids . ")");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
'lastname' => $products['customers_lastname'],
'email_address' => $products['customers_email_address']);
}
$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
'lastname' => $customers['customers_lastname'],
'email_address' => $customers['customers_email_address']);
}
}
$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
$mimemessage->add_text($this->content);
$mimemessage->build_message();
reset($audience);
while (list($key, $value) = each ($audience)) {
$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);
}
$newsletter_id = tep_db_prepare_input($newsletter_id);
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
}
?>
/*
$Id: product_notification.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 osCommerce
Released under the GNU General Public License
*/
class product_notification {
var $show_choose_audience, $title, $content;
function product_notification($title, $content) {
$this->show_choose_audience = true;
$this->title = $title;
$this->content = $content;
}
function choose_audience() {
global $HTTP_GET_VARS, $languages_id;
$products_array = array();
$products_query = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . $languages_id . "' and pd.products_id = p.products_id and p.products_status = '1' order by pd.products_name");
while ($products = tep_db_fetch_array($products_query)) {
$products_array[] = array('id' => $products['products_id'],
'text' => $products['products_name']);
}
$choose_audience_string = '<script language="javascript"><!--
function mover(move) {
if (move == \'remove\') {
for (x=0; x<(document.notifications.products.length); x++) {
if (document.notifications.products.options[x].selected) {
with(document.notifications.elements[\'chosen[]\']) {
options[options.length] = new Option(document.notifications.products.options[x].text,document.notifications.products.options[x].value);
}
document.notifications.products.options[x] = null;
x = -1;
}
}
}
if (move == \'add\') {
for (x=0; x<(document.notifications.elements[\'chosen[]\'].length); x++) {
if (document.notifications.elements[\'chosen[]\'].options[x].selected) {
with(document.notifications.products) {
options[options.length] = new Option(document.notifications.elements[\'chosen[]\'].options[x].text,document.notifications.elements[\'chosen[]\'].options[x].value);
}
document.notifications.elements[\'chosen[]\'].options[x] = null;
x = -1;
}
}
}
return true;
}
function selectAll(FormName, SelectBox) {
temp = "document." + FormName + ".elements[\'" + SelectBox + "\']";
Source = eval(temp);
for (x=0; x<(Source.length); x++) {
Source.options[x].selected = "true";
}
if (x<1) {
alert(\'' . JS_PLEASE_SELECT_PRODUCTS . '\');
return false;
} else {
return true;
}
}
//--></script>';
$global_button = '<script language="javascript"><!--' . "\n" .
'document.write(\'<input type="button" value="' . BUTTON_GLOBAL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '\\\'">\');' . "\n" .
'//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '">[ ' . BUTTON_GLOBAL . ' ]</a></noscript>';
$cancel_button = '<script language="javascript"><!--' . "\n" .
'document.write(\'<input type="button" value="' . BUTTON_CANCEL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '\\\'">\');' . "\n" .
'//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">[ ' . BUTTON_CANCEL . ' ]</a></noscript>';
$choose_audience_string .= '<form name="notifications" action="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm') . '" method="post" onSubmit="return selectAll(\'notifications\', \'chosen[]\')"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td align="center" class="main"><b>' . TEXT_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('products', $products_array, '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
' <td align="center" class="main"> <br>' . $global_button . '<br><br><br><input type="button" value="' . BUTTON_SELECT . '" style="width: 8em;" onClick="mover(\'remove\');"><br><br><input type="button" value="' . BUTTON_UNSELECT . '" style="width: 8em;" onClick="mover(\'add\');"><br><br><br><input type="submit" value="' . BUTTON_SUBMIT . '" style="width: 8em;"><br><br>' . $cancel_button . '</td>' . "\n" .
' <td align="center" class="main"><b>' . TEXT_SELECTED_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('chosen[]', array(), '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
' </tr>' . "\n" .
'</table></form>';
return $choose_audience_string;
}
function confirm() {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$audience = array();
if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
$products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS);
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = '1';
}
$customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_info_id']] = '1';
}
} else {
$chosen = $HTTP_POST_VARS['chosen'];
$ids = implode(',', $chosen);
$products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id in (" . $ids . ")");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = '1';
}
$customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_info_id']] = '1';
}
}
$confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, sizeof($audience)) . '</b></font></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><b>' . $this->title . '</b></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . tep_draw_form('confirm', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . "\n" .
' <td align="right">';
if (sizeof($audience) > 0) {
if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
$confirm_string .= tep_draw_hidden_field('global', 'true');
} else {
for ($i = 0, $n = sizeof($chosen); $i < $n; $i++) {
$confirm_string .= tep_draw_hidden_field('chosen[]', $chosen[$i]);
}
}
$confirm_string .= tep_image_submit('button_send.gif', IMAGE_SEND) . ' ';
}
$confirm_string .= '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=send') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "\n" .
' </tr>' . "\n" .
'</table>';
return $confirm_string;
}
function send($newsletter_id) {
global $HTTP_POST_VARS;
$audience = array();
if (isset($HTTP_POST_VARS['global']) && ($HTTP_POST_VARS['global'] == 'true')) {
$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
'lastname' => $products['customers_lastname'],
'email_address' => $products['customers_email_address']);
}
$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
'lastname' => $customers['customers_lastname'],
'email_address' => $customers['customers_email_address']);
}
} else {
$chosen = $HTTP_POST_VARS['chosen'];
$ids = implode(',', $chosen);
$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in (" . $ids . ")");
while ($products = tep_db_fetch_array($products_query)) {
$audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
'lastname' => $products['customers_lastname'],
'email_address' => $products['customers_email_address']);
}
$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
while ($customers = tep_db_fetch_array($customers_query)) {
$audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
'lastname' => $customers['customers_lastname'],
'email_address' => $customers['customers_email_address']);
}
}
$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
$mimemessage->add_text($this->content);
$mimemessage->build_message();
reset($audience);
while (list($key, $value) = each ($audience)) {
$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);
}
$newsletter_id = tep_db_prepare_input($newsletter_id);
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
}
?>
Wat zou ik moeten veranderen?
oei, hoe oud is die code?
Al een jaar of twaalf zeker gebruiken we in plaats daarvan $_POST die van nature al global is.
recente versies van PHP ondersteunen die lange versie zelfs niet meer (by default)
--
dit los van het rare-enters-probleem
Mij doen die /r en /n mij denken JSON datatypes.
Ik weet enkel dat ik die rare tekens weg wil, wat is de oplossing?
Volg het kruimelpad.
Allemaal chinees voor mij ;-)
wat is daar de inhoud van $this->content?
staan daar die \r en \n er al in?
Nee, de content is de mail zelf zeker die ik stuur?
probeer er eens een begrijpbaar stuk tekst van te maken
Zit er op regel 204 dus geen \n in $this->content?
Dan zit de fout dus in je mail-class.
Ik denk dat hier een programmeur beter in kan duiken, want dit via een forum debuggen wordt een nogal moeilijk schaakspel vrees ik.
EDIT: rechtstreeks induiken dus, dat iemand de sourcecode rechtstreeks in kan zien, het probleem is niet zozeer het probleem, maar meer de communicatie omtrent het probleem
Gewijzigd op 17/02/2015 17:02:14 door Thomas van den Heuvel
Zijn er hier programeurs in de zaal? :-)
- de code van de e-mail klasse (in dit bronbestand staat ergens class email {)
- een voorbeeld van invoer en uitvoer, die je al in je oorspronkelijke bericht gaf
Dus alleen het eerste puntje nog, voor dit moment.
Code (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
<?php
/*
$Id: email.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
mail.php - a class to assist in building mime-HTML eMails
The original class was made by Richard Heyes <[email protected]>
and can be found here: http://www.phpguru.org
Renamed and Modified by Jan Wildeboer for osCommerce
*/
class email {
var $html;
var $text;
var $output;
var $html_text;
var $html_images;
var $image_types;
var $build_params;
var $attachments;
var $headers;
function email($headers = '') {
if ($headers == '') $headers = array();
$this->html_images = array();
$this->headers = array();
if (EMAIL_LINEFEED == 'CRLF') {
$this->lf = "\r\n";
} else {
$this->lf = "\n";
}
/**
* If you want the auto load functionality
* to find other mime-image/file types, add the
* extension and content type here.
*/
$this->image_types = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash');
$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset'] = constant('CHARSET');
$this->build_params['text_charset'] = constant('CHARSET');
$this->build_params['text_wrap'] = 998;
/**
* Make sure the MIME version header is first.
*/
$this->headers[] = 'MIME-Version: 1.0';
reset($headers);
while (list(,$value) = each($headers)) {
if (tep_not_null($value)) {
$this->headers[] = $value;
}
}
}
/**
* This function will read a file in
* from a supplied filename and return
* it. This can then be given as the first
* argument of the the functions
* add_html_image() or add_attachment().
*/
function get_file($filename) {
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;
} else {
return false;
}
}
/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* Function contributed by Dan Allen
*/
function find_html_images($images_dir) {
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
for ($i=0; $i<count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (tep_not_null($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i=0; $i<count($html_images); $i++) {
if ($image = $this->get_file($images_dir . $html_images[$i])) {
$content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
$this->add_html_image($image, basename($html_images[$i]), $content_type);
}
}
}
}
/**
* Adds plain text. Use this function
* when NOT sending html email
*/
function add_text($text = '') {
$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
}
/**
* Adds a html part to the mail.
* Also replaces image names with
* content-id's.
*/
function add_html($html, $text = NULL, $images_dir = NULL) {
$this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), '<br>', $html);
$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
if (isset($images_dir)) $this->find_html_images($images_dir);
}
/**
* Adds an image to the list of embedded
* images.
*/
function add_html_image($file, $name = '', $c_type='application/octet-stream') {
$this->html_images[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time())));
}
/**
* Adds a file to the list of attachments.
*/
function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') {
$this->attachments[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'encoding' => $encoding);
}
/**
* Adds a text subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_text_part(&$obj, $text) {
function add_text_part(&$obj, $text) {
$params['content_type'] = 'text/plain';
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
return new mime($text, $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_part(&$obj) {
function add_html_part(&$obj) {
$params['content_type'] = 'text/html';
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
return $obj->addSubpart($this->html, $params);
} else {
return new mime($this->html, $params);
}
}
/**
* Starts a message with a mixed part
*/
/* HPDL PHP3 */
// function &add_mixed_part() {
function add_mixed_part() {
$params['content_type'] = 'multipart/mixed';
return new mime('', $params);
}
/**
* Adds an alternative part to a mime_part object
*/
/* HPDL PHP3 */
// function &add_alternative_part(&$obj) {
function add_alternative_part(&$obj) {
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_related_part(&$obj) {
function add_related_part(&$obj) {
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds an html image subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_image_part(&$obj, $value) {
function add_html_image_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['cid'] = $value['cid'];
$obj->addSubpart($value['body'], $params);
}
/**
* Adds an attachment subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_attachment_part(&$obj, $value) {
function add_attachment_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition'] = 'attachment';
$params['dfilename'] = $value['name'];
$obj->addSubpart($value['body'], $params);
}
/**
* Builds the multipart message from the
* list ($this->_parts). $params is an
* array of parameters that shape the building
* of the message. Currently supported are:
*
* $params['html_encoding'] - The type of encoding to use on html. Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable
* $params['text_encoding'] - The type of encoding to use on plain text Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* Default is 7bit
* $params['text_wrap'] - The character count at which to wrap 7bit encoded data.
* Default this is 998.
* $params['html_charset'] - The character set to use for a html section.
* Default is iso-8859-1
* $params['text_charset'] - The character set to use for a text section.
* - Default is iso-8859-1
*/
/* HPDL PHP3 */
// function build_message($params = array()) {
function build_message($params = '') {
if ($params == '') $params = array();
if (count($params) > 0) {
reset($params);
while(list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}
if (tep_not_null($this->html_images)) {
reset($this->html_images);
while (list(,$value) = each($this->html_images)) {
$this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
}
}
$null = NULL;
$attachments = ((tep_not_null($this->attachments)) ? true : false);
$html_images = ((tep_not_null($this->html_images)) ? true : false);
$html = ((tep_not_null($this->html)) ? true : false);
$text = ((tep_not_null($this->text)) ? true : false);
switch (true) {
case (($text == true) && ($attachments == false)):
/* HPDL PHP3 */
// $message =& $this->add_text_part($null, $this->text);
$message = $this->add_text_part($null, $this->text);
break;
case (($text == false) && ($attachments == true) && ($html == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($text == true) && ($attachments == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
$this->add_text_part($message, $this->text);
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == false)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
$this->add_html_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_html_part($null);
$message = $this->add_html_part($null);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == true)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
/* HPDL PHP3 */
// $related =& $this->add_related_part($message);
$related = $this->add_related_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_related_part($null);
// $related =& $message;
$message = $this->add_related_part($null);
$related = $message;
}
$this->add_html_part($related);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($related, $this->html_images[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
$this->add_html_part($alt);
} else {
$this->add_html_part($message);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
/* HPDL PHP3 */
// $rel =& $this->add_related_part($alt);
$rel = $this->add_related_part($alt);
} else {
/* HPDL PHP3 */
// $rel =& $this->add_related_part($message);
$rel = $this->add_related_part($message);
}
$this->add_html_part($rel);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($rel, $this->html_images[$i]);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
}
if ( (isset($message)) && (is_object($message)) ) {
$output = $message->encode();
$this->output = $output['body'];
reset($output['headers']);
while (list($key, $value) = each($output['headers'])) {
$headers[] = $key . ': ' . $value;
}
$this->headers = array_merge($this->headers, $headers);
return true;
} else {
return false;
}
}
/**
* Sends the mail.
*/
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
return false;
}
if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
return false;
}
if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
return false;
}
if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
return false;
}
if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
return false;
}
$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
} else {
return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
}
}
/**
* Use this method to return the email
* in message/rfc822 format. Useful for
* adding an email to another email as
* an attachment. there's a commented
* out example in example.php.
*
* string get_rfc822(string To name,
* string To email,
* string From name,
* string From email,
* [string Subject,
* string Extra headers])
*/
function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
// Make up the date header as according to RFC822
$date = 'Date: ' . date('D, d M y H:i:s');
$to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);
$from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);
if (is_string($subject)) {
$subject = 'Subject: ' . $subject;
}
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
$headers = array_merge($this->headers, $xtra_headers);
return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;
}
}
?>
/*
$Id: email.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
mail.php - a class to assist in building mime-HTML eMails
The original class was made by Richard Heyes <[email protected]>
and can be found here: http://www.phpguru.org
Renamed and Modified by Jan Wildeboer for osCommerce
*/
class email {
var $html;
var $text;
var $output;
var $html_text;
var $html_images;
var $image_types;
var $build_params;
var $attachments;
var $headers;
function email($headers = '') {
if ($headers == '') $headers = array();
$this->html_images = array();
$this->headers = array();
if (EMAIL_LINEFEED == 'CRLF') {
$this->lf = "\r\n";
} else {
$this->lf = "\n";
}
/**
* If you want the auto load functionality
* to find other mime-image/file types, add the
* extension and content type here.
*/
$this->image_types = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash');
$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset'] = constant('CHARSET');
$this->build_params['text_charset'] = constant('CHARSET');
$this->build_params['text_wrap'] = 998;
/**
* Make sure the MIME version header is first.
*/
$this->headers[] = 'MIME-Version: 1.0';
reset($headers);
while (list(,$value) = each($headers)) {
if (tep_not_null($value)) {
$this->headers[] = $value;
}
}
}
/**
* This function will read a file in
* from a supplied filename and return
* it. This can then be given as the first
* argument of the the functions
* add_html_image() or add_attachment().
*/
function get_file($filename) {
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;
} else {
return false;
}
}
/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* Function contributed by Dan Allen
*/
function find_html_images($images_dir) {
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
for ($i=0; $i<count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (tep_not_null($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i=0; $i<count($html_images); $i++) {
if ($image = $this->get_file($images_dir . $html_images[$i])) {
$content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
$this->add_html_image($image, basename($html_images[$i]), $content_type);
}
}
}
}
/**
* Adds plain text. Use this function
* when NOT sending html email
*/
function add_text($text = '') {
$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
}
/**
* Adds a html part to the mail.
* Also replaces image names with
* content-id's.
*/
function add_html($html, $text = NULL, $images_dir = NULL) {
$this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), '<br>', $html);
$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
if (isset($images_dir)) $this->find_html_images($images_dir);
}
/**
* Adds an image to the list of embedded
* images.
*/
function add_html_image($file, $name = '', $c_type='application/octet-stream') {
$this->html_images[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time())));
}
/**
* Adds a file to the list of attachments.
*/
function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') {
$this->attachments[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'encoding' => $encoding);
}
/**
* Adds a text subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_text_part(&$obj, $text) {
function add_text_part(&$obj, $text) {
$params['content_type'] = 'text/plain';
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
return new mime($text, $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_part(&$obj) {
function add_html_part(&$obj) {
$params['content_type'] = 'text/html';
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
return $obj->addSubpart($this->html, $params);
} else {
return new mime($this->html, $params);
}
}
/**
* Starts a message with a mixed part
*/
/* HPDL PHP3 */
// function &add_mixed_part() {
function add_mixed_part() {
$params['content_type'] = 'multipart/mixed';
return new mime('', $params);
}
/**
* Adds an alternative part to a mime_part object
*/
/* HPDL PHP3 */
// function &add_alternative_part(&$obj) {
function add_alternative_part(&$obj) {
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_related_part(&$obj) {
function add_related_part(&$obj) {
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds an html image subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_image_part(&$obj, $value) {
function add_html_image_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['cid'] = $value['cid'];
$obj->addSubpart($value['body'], $params);
}
/**
* Adds an attachment subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_attachment_part(&$obj, $value) {
function add_attachment_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition'] = 'attachment';
$params['dfilename'] = $value['name'];
$obj->addSubpart($value['body'], $params);
}
/**
* Builds the multipart message from the
* list ($this->_parts). $params is an
* array of parameters that shape the building
* of the message. Currently supported are:
*
* $params['html_encoding'] - The type of encoding to use on html. Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable
* $params['text_encoding'] - The type of encoding to use on plain text Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* Default is 7bit
* $params['text_wrap'] - The character count at which to wrap 7bit encoded data.
* Default this is 998.
* $params['html_charset'] - The character set to use for a html section.
* Default is iso-8859-1
* $params['text_charset'] - The character set to use for a text section.
* - Default is iso-8859-1
*/
/* HPDL PHP3 */
// function build_message($params = array()) {
function build_message($params = '') {
if ($params == '') $params = array();
if (count($params) > 0) {
reset($params);
while(list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}
if (tep_not_null($this->html_images)) {
reset($this->html_images);
while (list(,$value) = each($this->html_images)) {
$this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
}
}
$null = NULL;
$attachments = ((tep_not_null($this->attachments)) ? true : false);
$html_images = ((tep_not_null($this->html_images)) ? true : false);
$html = ((tep_not_null($this->html)) ? true : false);
$text = ((tep_not_null($this->text)) ? true : false);
switch (true) {
case (($text == true) && ($attachments == false)):
/* HPDL PHP3 */
// $message =& $this->add_text_part($null, $this->text);
$message = $this->add_text_part($null, $this->text);
break;
case (($text == false) && ($attachments == true) && ($html == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($text == true) && ($attachments == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
$this->add_text_part($message, $this->text);
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == false)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
$this->add_html_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_html_part($null);
$message = $this->add_html_part($null);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == true)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
/* HPDL PHP3 */
// $related =& $this->add_related_part($message);
$related = $this->add_related_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_related_part($null);
// $related =& $message;
$message = $this->add_related_part($null);
$related = $message;
}
$this->add_html_part($related);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($related, $this->html_images[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
$this->add_html_part($alt);
} else {
$this->add_html_part($message);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
/* HPDL PHP3 */
// $rel =& $this->add_related_part($alt);
$rel = $this->add_related_part($alt);
} else {
/* HPDL PHP3 */
// $rel =& $this->add_related_part($message);
$rel = $this->add_related_part($message);
}
$this->add_html_part($rel);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($rel, $this->html_images[$i]);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
}
if ( (isset($message)) && (is_object($message)) ) {
$output = $message->encode();
$this->output = $output['body'];
reset($output['headers']);
while (list($key, $value) = each($output['headers'])) {
$headers[] = $key . ': ' . $value;
}
$this->headers = array_merge($this->headers, $headers);
return true;
} else {
return false;
}
}
/**
* Sends the mail.
*/
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
return false;
}
if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
return false;
}
if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
return false;
}
if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
return false;
}
if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
return false;
}
$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
} else {
return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
}
}
/**
* Use this method to return the email
* in message/rfc822 format. Useful for
* adding an email to another email as
* an attachment. there's a commented
* out example in example.php.
*
* string get_rfc822(string To name,
* string To email,
* string From name,
* string From email,
* [string Subject,
* string Extra headers])
*/
function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
// Make up the date header as according to RFC822
$date = 'Date: ' . date('D, d M y H:i:s');
$to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);
$from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);
if (is_string($subject)) {
$subject = 'Subject: ' . $subject;
}
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
$headers = array_merge($this->headers, $xtra_headers);
return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;
}
}
?>
Toevoeging op 17/02/2015 20:45:53:
Dit is email.php in de Admin sectie (folder)
Code (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
<?php
/*
$Id: email.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
mail.php - a class to assist in building mime-HTML eMails
The original class was made by Richard Heyes <[email protected]>
and can be found here: http://www.phpguru.org
Renamed and Modified by Jan Wildeboer for osCommerce
*/
class email {
var $html;
var $text;
var $output;
var $html_text;
var $html_images;
var $image_types;
var $build_params;
var $attachments;
var $headers;
function email($headers = '') {
if ($headers == '') $headers = array();
$this->html_images = array();
$this->headers = array();
if (EMAIL_LINEFEED == 'CRLF') {
$this->lf = "\r\n";
} else {
$this->lf = "\n";
}
/**
* If you want the auto load functionality
* to find other mime-image/file types, add the
* extension and content type here.
*/
$this->image_types = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash');
$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset'] = constant('CHARSET');
$this->build_params['text_charset'] = constant('CHARSET');
$this->build_params['text_wrap'] = 998;
/**
* Make sure the MIME version header is first.
*/
$this->headers[] = 'MIME-Version: 1.0';
reset($headers);
while (list(,$value) = each($headers)) {
if (tep_not_null($value)) {
$this->headers[] = $value;
}
}
}
/**
* This function will read a file in
* from a supplied filename and return
* it. This can then be given as the first
* argument of the the functions
* add_html_image() or add_attachment().
*/
function get_file($filename) {
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;
} else {
return false;
}
}
/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* Function contributed by Dan Allen
*/
function find_html_images($images_dir) {
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
for ($i=0; $i<count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (tep_not_null($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i=0; $i<count($html_images); $i++) {
if ($image = $this->get_file($images_dir . $html_images[$i])) {
$content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
$this->add_html_image($image, basename($html_images[$i]), $content_type);
}
}
}
}
/**
* Adds plain text. Use this function
* when NOT sending html email
*/
function add_text($text = '') {
$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
}
/**
* Adds a html part to the mail.
* Also replaces image names with
* content-id's.
*/
function add_html($html, $text = NULL, $images_dir = NULL) {
$this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), '<br>', $html);
$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
if (isset($images_dir)) $this->find_html_images($images_dir);
}
/**
* Adds an image to the list of embedded
* images.
*/
function add_html_image($file, $name = '', $c_type='application/octet-stream') {
$this->html_images[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time())));
}
/**
* Adds a file to the list of attachments.
*/
function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') {
$this->attachments[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'encoding' => $encoding);
}
/**
* Adds a text subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_text_part(&$obj, $text) {
function add_text_part(&$obj, $text) {
$params['content_type'] = 'text/plain';
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
return new mime($text, $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_part(&$obj) {
function add_html_part(&$obj) {
$params['content_type'] = 'text/html';
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
return $obj->addSubpart($this->html, $params);
} else {
return new mime($this->html, $params);
}
}
/**
* Starts a message with a mixed part
*/
/* HPDL PHP3 */
// function &add_mixed_part() {
function add_mixed_part() {
$params['content_type'] = 'multipart/mixed';
return new mime('', $params);
}
/**
* Adds an alternative part to a mime_part object
*/
/* HPDL PHP3 */
// function &add_alternative_part(&$obj) {
function add_alternative_part(&$obj) {
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_related_part(&$obj) {
function add_related_part(&$obj) {
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds an html image subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_image_part(&$obj, $value) {
function add_html_image_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['cid'] = $value['cid'];
$obj->addSubpart($value['body'], $params);
}
/**
* Adds an attachment subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_attachment_part(&$obj, $value) {
function add_attachment_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition'] = 'attachment';
$params['dfilename'] = $value['name'];
$obj->addSubpart($value['body'], $params);
}
/**
* Builds the multipart message from the
* list ($this->_parts). $params is an
* array of parameters that shape the building
* of the message. Currently supported are:
*
* $params['html_encoding'] - The type of encoding to use on html. Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable
* $params['text_encoding'] - The type of encoding to use on plain text Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* Default is 7bit
* $params['text_wrap'] - The character count at which to wrap 7bit encoded data.
* Default this is 998.
* $params['html_charset'] - The character set to use for a html section.
* Default is iso-8859-1
* $params['text_charset'] - The character set to use for a text section.
* - Default is iso-8859-1
*/
/* HPDL PHP3 */
// function build_message($params = array()) {
function build_message($params = '') {
if ($params == '') $params = array();
if (count($params) > 0) {
reset($params);
while(list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}
if (tep_not_null($this->html_images)) {
reset($this->html_images);
while (list(,$value) = each($this->html_images)) {
$this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
}
}
$null = NULL;
$attachments = ((tep_not_null($this->attachments)) ? true : false);
$html_images = ((tep_not_null($this->html_images)) ? true : false);
$html = ((tep_not_null($this->html)) ? true : false);
$text = ((tep_not_null($this->text)) ? true : false);
switch (true) {
case (($text == true) && ($attachments == false)):
/* HPDL PHP3 */
// $message =& $this->add_text_part($null, $this->text);
$message = $this->add_text_part($null, $this->text);
break;
case (($text == false) && ($attachments == true) && ($html == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($text == true) && ($attachments == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
$this->add_text_part($message, $this->text);
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == false)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
$this->add_html_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_html_part($null);
$message = $this->add_html_part($null);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == true)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
/* HPDL PHP3 */
// $related =& $this->add_related_part($message);
$related = $this->add_related_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_related_part($null);
// $related =& $message;
$message = $this->add_related_part($null);
$related = $message;
}
$this->add_html_part($related);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($related, $this->html_images[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
$this->add_html_part($alt);
} else {
$this->add_html_part($message);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
/* HPDL PHP3 */
// $rel =& $this->add_related_part($alt);
$rel = $this->add_related_part($alt);
} else {
/* HPDL PHP3 */
// $rel =& $this->add_related_part($message);
$rel = $this->add_related_part($message);
}
$this->add_html_part($rel);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($rel, $this->html_images[$i]);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
}
if ( (isset($message)) && (is_object($message)) ) {
$output = $message->encode();
$this->output = $output['body'];
reset($output['headers']);
while (list($key, $value) = each($output['headers'])) {
$headers[] = $key . ': ' . $value;
}
$this->headers = array_merge($this->headers, $headers);
return true;
} else {
return false;
}
}
/**
* Sends the mail.
*/
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
return false;
}
if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
return false;
}
if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
return false;
}
if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
return false;
}
if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
return false;
}
$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
} else {
return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
}
}
/**
* Use this method to return the email
* in message/rfc822 format. Useful for
* adding an email to another email as
* an attachment. there's a commented
* out example in example.php.
*
* string get_rfc822(string To name,
* string To email,
* string From name,
* string From email,
* [string Subject,
* string Extra headers])
*/
function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
// Make up the date header as according to RFC822
$date = 'Date: ' . date('D, d M y H:i:s');
$to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);
$from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);
if (is_string($subject)) {
$subject = 'Subject: ' . $subject;
}
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
$headers = array_merge($this->headers, $xtra_headers);
return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;
}
}
?>
/*
$Id: email.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
mail.php - a class to assist in building mime-HTML eMails
The original class was made by Richard Heyes <[email protected]>
and can be found here: http://www.phpguru.org
Renamed and Modified by Jan Wildeboer for osCommerce
*/
class email {
var $html;
var $text;
var $output;
var $html_text;
var $html_images;
var $image_types;
var $build_params;
var $attachments;
var $headers;
function email($headers = '') {
if ($headers == '') $headers = array();
$this->html_images = array();
$this->headers = array();
if (EMAIL_LINEFEED == 'CRLF') {
$this->lf = "\r\n";
} else {
$this->lf = "\n";
}
/**
* If you want the auto load functionality
* to find other mime-image/file types, add the
* extension and content type here.
*/
$this->image_types = array('gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash');
$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset'] = constant('CHARSET');
$this->build_params['text_charset'] = constant('CHARSET');
$this->build_params['text_wrap'] = 998;
/**
* Make sure the MIME version header is first.
*/
$this->headers[] = 'MIME-Version: 1.0';
reset($headers);
while (list(,$value) = each($headers)) {
if (tep_not_null($value)) {
$this->headers[] = $value;
}
}
}
/**
* This function will read a file in
* from a supplied filename and return
* it. This can then be given as the first
* argument of the the functions
* add_html_image() or add_attachment().
*/
function get_file($filename) {
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;
} else {
return false;
}
}
/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* Function contributed by Dan Allen
*/
function find_html_images($images_dir) {
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
for ($i=0; $i<count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (tep_not_null($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i=0; $i<count($html_images); $i++) {
if ($image = $this->get_file($images_dir . $html_images[$i])) {
$content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
$this->add_html_image($image, basename($html_images[$i]), $content_type);
}
}
}
}
/**
* Adds plain text. Use this function
* when NOT sending html email
*/
function add_text($text = '') {
$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
}
/**
* Adds a html part to the mail.
* Also replaces image names with
* content-id's.
*/
function add_html($html, $text = NULL, $images_dir = NULL) {
$this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), '<br>', $html);
$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
if (isset($images_dir)) $this->find_html_images($images_dir);
}
/**
* Adds an image to the list of embedded
* images.
*/
function add_html_image($file, $name = '', $c_type='application/octet-stream') {
$this->html_images[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time())));
}
/**
* Adds a file to the list of attachments.
*/
function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') {
$this->attachments[] = array('body' => $file,
'name' => $name,
'c_type' => $c_type,
'encoding' => $encoding);
}
/**
* Adds a text subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_text_part(&$obj, $text) {
function add_text_part(&$obj, $text) {
$params['content_type'] = 'text/plain';
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
return new mime($text, $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_part(&$obj) {
function add_html_part(&$obj) {
$params['content_type'] = 'text/html';
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
return $obj->addSubpart($this->html, $params);
} else {
return new mime($this->html, $params);
}
}
/**
* Starts a message with a mixed part
*/
/* HPDL PHP3 */
// function &add_mixed_part() {
function add_mixed_part() {
$params['content_type'] = 'multipart/mixed';
return new mime('', $params);
}
/**
* Adds an alternative part to a mime_part object
*/
/* HPDL PHP3 */
// function &add_alternative_part(&$obj) {
function add_alternative_part(&$obj) {
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds a html subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_related_part(&$obj) {
function add_related_part(&$obj) {
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new mime('', $params);
}
}
/**
* Adds an html image subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_html_image_part(&$obj, $value) {
function add_html_image_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['cid'] = $value['cid'];
$obj->addSubpart($value['body'], $params);
}
/**
* Adds an attachment subpart to a mime_part object
*/
/* HPDL PHP3 */
// function &add_attachment_part(&$obj, $value) {
function add_attachment_part(&$obj, $value) {
$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition'] = 'attachment';
$params['dfilename'] = $value['name'];
$obj->addSubpart($value['body'], $params);
}
/**
* Builds the multipart message from the
* list ($this->_parts). $params is an
* array of parameters that shape the building
* of the message. Currently supported are:
*
* $params['html_encoding'] - The type of encoding to use on html. Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable
* $params['text_encoding'] - The type of encoding to use on plain text Valid options are
* "7bit", "quoted-printable" or "base64" (all without quotes).
* Default is 7bit
* $params['text_wrap'] - The character count at which to wrap 7bit encoded data.
* Default this is 998.
* $params['html_charset'] - The character set to use for a html section.
* Default is iso-8859-1
* $params['text_charset'] - The character set to use for a text section.
* - Default is iso-8859-1
*/
/* HPDL PHP3 */
// function build_message($params = array()) {
function build_message($params = '') {
if ($params == '') $params = array();
if (count($params) > 0) {
reset($params);
while(list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}
if (tep_not_null($this->html_images)) {
reset($this->html_images);
while (list(,$value) = each($this->html_images)) {
$this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
}
}
$null = NULL;
$attachments = ((tep_not_null($this->attachments)) ? true : false);
$html_images = ((tep_not_null($this->html_images)) ? true : false);
$html = ((tep_not_null($this->html)) ? true : false);
$text = ((tep_not_null($this->text)) ? true : false);
switch (true) {
case (($text == true) && ($attachments == false)):
/* HPDL PHP3 */
// $message =& $this->add_text_part($null, $this->text);
$message = $this->add_text_part($null, $this->text);
break;
case (($text == false) && ($attachments == true) && ($html == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($text == true) && ($attachments == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
$this->add_text_part($message, $this->text);
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == false)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
$this->add_html_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_html_part($null);
$message = $this->add_html_part($null);
}
break;
case (($html == true) && ($attachments == false) && ($html_images == true)):
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $message =& $this->add_alternative_part($null);
$message = $this->add_alternative_part($null);
$this->add_text_part($message, $this->html_text);
/* HPDL PHP3 */
// $related =& $this->add_related_part($message);
$related = $this->add_related_part($message);
} else {
/* HPDL PHP3 */
// $message =& $this->add_related_part($null);
// $related =& $message;
$message = $this->add_related_part($null);
$related = $message;
}
$this->add_html_part($related);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($related, $this->html_images[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == false)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
$this->add_html_part($alt);
} else {
$this->add_html_part($message);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
case (($html == true) && ($attachments == true) && ($html_images == true)):
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
// $alt =& $this->add_alternative_part($message);
$alt = $this->add_alternative_part($message);
$this->add_text_part($alt, $this->html_text);
/* HPDL PHP3 */
// $rel =& $this->add_related_part($alt);
$rel = $this->add_related_part($alt);
} else {
/* HPDL PHP3 */
// $rel =& $this->add_related_part($message);
$rel = $this->add_related_part($message);
}
$this->add_html_part($rel);
for ($i=0; $i<count($this->html_images); $i++) {
$this->add_html_image_part($rel, $this->html_images[$i]);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
}
if ( (isset($message)) && (is_object($message)) ) {
$output = $message->encode();
$this->output = $output['body'];
reset($output['headers']);
while (list($key, $value) = each($output['headers'])) {
$headers[] = $key . ': ' . $value;
}
$this->headers = array_merge($this->headers, $headers);
return true;
} else {
return false;
}
}
/**
* Sends the mail.
*/
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
return false;
}
if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
return false;
}
if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
return false;
}
if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
return false;
}
if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
return false;
}
$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
} else {
return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
}
}
/**
* Use this method to return the email
* in message/rfc822 format. Useful for
* adding an email to another email as
* an attachment. there's a commented
* out example in example.php.
*
* string get_rfc822(string To name,
* string To email,
* string From name,
* string From email,
* [string Subject,
* string Extra headers])
*/
function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
// Make up the date header as according to RFC822
$date = 'Date: ' . date('D, d M y H:i:s');
$to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);
$from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);
if (is_string($subject)) {
$subject = 'Subject: ' . $subject;
}
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
$headers = array_merge($this->headers, $xtra_headers);
return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;
}
}
?>
Toevoeging op 17/02/2015 20:46:34:
Zal waarschijnlijk aan de class email {
var $html;
var $text;
var $output;
var $html_text;
var $html_images;
var $image_types;
var $build_params;
var $attachments;
var $headers; liggen hé.....
Moet ik hier iets veranderen?
Niemand die mij hier kan helpen?