Detail: This send HTML email to users. This topic is use with other MOD I post (no work with MSN).
Use ZIP file attachment. Upload content to includes/html_email (create folder).
Here is test PHP script for 4images. Is send 3 last upload image of gallery and to
all admin (allow email accept - if no - no send).
// Step 1
In ROOT_PATH, create file:
mail-client.php file.
Add:
<?php
define('ROOT_PATH', './');
include(ROOT_PATH . 'global.php');
require(ROOT_PATH . 'includes/sessions.php');
@include_once(ROOT_PATH . 'includes/page_header.php');
if ($user_info['user_level'] == ADMIN) {
$sql = "
SELECT image_id, image_name, cat_id, image_media_file
FROM " . IMAGES_TABLE . "
WHERE image_active = 1 AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
ORDER BY image_date DESC
LIMIT 2
";
$result = $site_db->query($sql);
@include_once(ROOT_PATH . 'includes/html_email/MAIL.php');
// get ID value (random) for the embed image
$id = MIME::unique();
$site_email = new MAIL;
$image_url = "";
while ($image_row = $site_db->fetch_array($result)) {
$image_url .= preg_replace("/" . $site_template->start . "image_url" . $site_template->end . "/siU", format_url($script_url . '/details.php?image_id=' . (int)$image_row['image_id']), $lang['latest_image_by_email_message_url']);
$f = ROOT_PATH . 'data/media/' . $image_row['cat_id'] . '/' . $image_row['image_media_file'];
$site_email->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'inline', $id);
}
$sql1 = "
SELECT " . get_user_table_field("", "user_name") . get_user_table_field(", ", "user_email") . "
FROM " . USERS_TABLE . "
WHERE " . get_user_table_field("", "user_level") . " >= '" . ADMIN . "' AND " . get_user_table_field("", "user_allowemails") . " = 1 AND " . get_user_table_field("", "user_id") . " != 1";
$result1 = $site_db->query($sql1);
$site_email->From($config['site_email'], format_text($config['site_name'], 2));
$site_email->AddTo($user_info['user_email'], format_text(trim($user_info['user_name']), 2));
$email_row = array();
while ($row = $site_db->fetch_array($result1)) {
$email_row[] = $row;
}
$site_db->free_result($result1);
$num_email = sizeof($email_row);
$user_email = "";
$user_name = "";
for ($i = 0; $i < $num_email; $i++) {
if (FUNC::is_mail($email_row[$i][$user_table_fields['user_email']], true) && !preg_match("/[\msn]/i", $email_row[$i][$user_table_fields['user_email']])) {
$user_email .= $email_row[$i][$user_table_fields['user_email']] . ", ";
$user_name .= $email_row[$i][$user_table_fields['user_name']] . ", ";
}
}
if (isset($user_name) && !empty($user_name) && isset($user_email) && !empty($user_email)) {
$user_name_sub = substr($user_name, 0, strlen($user_name) -2);
$user_email_sub = substr($user_email, 0, strlen($user_email) -2);
$site_email->Cc[] = array(
'address' => stripslashes($user_email_sub), // required
'name' => format_text(trim($user_name_sub), 2), // optional
'charset' => $lang['charset'], // optional
'encoding' => 'base64' // optional
);
$site_email->Subject('Latest image');
}
@include_once(ROOT_PATH . 'lang/' . $config['language_dir'] . '/html_email/my_template.php');
$site_email->Html($email_template);
echo $site_email->Send('client') ? $lang['latest_image_by_email_sent'] : $lang['latest_image_by_email_error'];
$site_email->Delto();
$site_email->Delcc();
$site_email->DelAttach();
$site_email->Disconnect();
unset ($email_row);
unset ($image_url);
unset ($user_name);
unset ($user_email);
}
@include_once(ROOT_PATH . 'includes/page_footer.php');
?>
// Step 2
In lang/english folder, create folder:
html_email . Create file:
my_template.php (yes, is true filename for test - no replace to real template name).
Add:
<?php
if (!defined('ROOT_PATH')) {
die ('Security violation.');
}
$email_template = stripslashes('
<html>
<body bgcolor="#FFFFFF" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">
<br />
<table width="640" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/header_top.gif" width="640" height="6" alt="" /></td>
</tr>
<tr>
<td width="6"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/header_left.gif" width="6" height="60" alt="" /></td>
<td width="405"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/header_logo.gif" width="405" height="60" alt="" /></td>
<td width="225" align="right"> </td>
<td align="right" width="6"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/header_right.gif" width="6" height="60" alt="" /></td>
</tr>
</table>
<table width="640" border="1" cellspacing="1" cellpadding="0">
<tr>
<td width="450" align="center"><font color="green"><br />Dear ' . format_text(trim($user_info['user_name']), 2) . ',<br /><br />
We now present you the latest upload image in gallery: <b>' . format_text($image_info['image_name'], 2) . '</b><br /><br />
' . $image_url . '<br /><br /></font></td>
</tr>
</table>
<table width="640" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/footer_left.gif" width="6" height="19" alt="" /></td>
<td width="405"> </td>
<td width="225"> </td>
<td width="6"><img src="' . $script_url . '/' . TEMPLATE_PATH . '/images/footer_right.gif" width="6" height="19" alt="" /></td>
</tr>
</table>
<p id="copyright" align="center">
Powered by <b>4images</b> v1.7.4
<br />
Copyright © 2002-2007 <a href="http://www.4homepages.de" target="_blank">4homepages.de</a>
</p>
</body>
</html>
');
?>
// Step 3
In lang/english/main.php file,
add top ?>:
$lang['latest_image_by_email_message_url'] = "Go see <a href=\"{image_url}\">here</a><br />";
$lang['latest_image_by_email_sent'] = "Email sent !";
$lang['latest_image_by_email_error'] = "Error while sending email. Please check mail / web logs (cPanel access) and post in 4homepages.de forum - official topic - if need help.";
Should work.