This MOD will let you/your visitors send a postcard (eCard) to multyple email addresses (recipients) at ones.
The email addresses must be separated by coma ( , ) or semicolon ( ; )
i.e. someone@domain.com, someoneelse@domain.com;dog@cat.com
To each recipient, 4images will send individual postcard, with unique ID using " TO: " instead of " BCC: " as in ACP, so, if u installed "
Notify sender on received postcard" it wont affect anything.
(@Chris: if u still need the changes in admin "send email to users", I think it will be 10 min work
)
- If one or more recipient email addresses are in wrong format it will show witch address should be corrected.
- It checks if in the recipients email addresses list has doublicate adresses and doesnt send more then one email for each unique email address.
The only draw-back right now, is that the "Recipient name" will be used for each recipient...
. At the begining I was thinking to force sender to enter name for each email address, separated by coma or semicolon...but then, it will be too confusing.
While I was typing this, I got another idea: using ONE text_area to enter username and email address for each recipient (one recipient per line). Well, will need some feedback from u guys, with more ideas
ExampleAnd finaly after all that boring overview here what u need to do:
1.Open
/postcards.phpFind:
$back_url = (!empty($HTTP_POST_VARS['back_url'])) ? stripslashes(trim($HTTP_POST_VARS['back_url'])) : $site_sess->url(ROOT_PATH."index.php", "&");
$postcard_id = get_random_key(POSTCARDS_TABLE, "postcard_id");
$current_time = time();
$sql = "INSERT INTO ".POSTCARDS_TABLE."
(postcard_id, image_id, postcard_date, postcard_bg_color, postcard_border_color, postcard_font_color, postcard_font_face, postcard_sender_name, postcard_sender_email, postcard_recipient_name, postcard_recipient_email, postcard_headline, postcard_message)
VALUES
('$postcard_id', $image_id, $current_time, '$bg_color', '$border_color', '$font_color', '$font_face', '$sender_name', '$sender_email', '$recipient_name', '$recipient_email', '$headline', '$message')";
$result = $site_db->query($sql);
if ($result) {
$postcard_url = $script_url."/postcards.php?".URL_POSTCARD_ID."=".$postcard_id;
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_to(stripslashes($recipient_email));
$site_email->set_from(stripslashes($sender_email), stripslashes($sender_name));
$site_email->set_subject($lang['send_postcard_emailsubject']);
$site_email->register_vars(array(
"sender_name" => stripslashes($sender_name),
"sender_email" => stripslashes($sender_email),
"recipient_name" => stripslashes($recipient_name),
"postcard_url" => stripslashes($postcard_url),
"postcard_send_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
"site_name" => $config['site_name']
));
$site_email->set_body("postcard_message", $config['language_dir']);
$site_email->send_email();
$msg .= $lang['send_postcard_success'];
$msg .= "<br /><a href=\"".$back_url."\">".$lang['back_to_gallery']."</a>";
$action = "showcard";
}
else {
$msg = $lang['general_error'];
$action = "previewcard";
$main_template = "postcard_preview";
}
}
if ($action == "showcard") {
Replace with:
$back_url = (!empty($HTTP_POST_VARS['back_url'])) ? stripslashes(trim($HTTP_POST_VARS['back_url'])) : $site_sess->url(ROOT_PATH."index.php", "&");
include(ROOT_PATH.'includes/email.php');
$recipient_email_temp = $recipient_email;
$recipient_email_temp = str_replace(" ", "", $recipient_email_temp);
$recipient_email_temp = str_replace(";", ",", $recipient_email_temp);
$recipient_email_array = explode(",", $recipient_email_temp);
$recipient_email_cache = array();
foreach ($recipient_email_array as $key) {
if (!in_array($key, $recipient_email_cache)) {
$recipient_email_cache[] = $key;
$postcard_id = get_random_key(POSTCARDS_TABLE, "postcard_id");
$current_time = time();
$sql = "INSERT INTO ".POSTCARDS_TABLE."
(postcard_id, image_id, postcard_date, postcard_bg_color, postcard_border_color, postcard_font_color, postcard_font_face, postcard_sender_name, postcard_sender_email, postcard_recipient_name, postcard_recipient_email, postcard_headline, postcard_message)
VALUES
('$postcard_id', $image_id, $current_time, '$bg_color', '$border_color', '$font_color', '$font_face', '$sender_name', '$sender_email', '$recipient_name', '$key', '$headline', '$message')";
$result = $site_db->query($sql);
if ($result) {
$postcard_url = $script_url."/postcards.php?".URL_POSTCARD_ID."=".$postcard_id;
$site_email = new Email();
$site_email->set_to(stripslashes($key));
$site_email->set_from(stripslashes($sender_email), stripslashes($sender_name));
$site_email->set_subject($lang['send_postcard_emailsubject']);
$site_email->register_vars(array(
"sender_name" => stripslashes($sender_name),
"sender_email" => stripslashes($sender_email),
"recipient_name" => stripslashes($recipient_name),
"postcard_url" => stripslashes($postcard_url),
"postcard_send_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
"site_name" => $config['site_name']
));
$site_email->set_body("postcard_message", $config['language_dir']);
$site_email->send_email();
}
else {
$msg = $lang['general_error'];
$action = "previewcard";
$main_template = "postcard_preview";
exit;
}
}
}
$msg .= $lang['send_postcard_success']."<br />( ".$recipient_email_temp." )";
$msg_color = 1;
$msg .= "<br /><a href=\"".$back_url."\">".$lang['back_to_gallery']."</a>";
$action = "showcard";
}
if ($action == "showcard") {
1.2.Find:
if (($sender_email != "" && !check_email($sender_email)) || ($recipient_email != "" && !check_email($recipient_email))) {
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$error = 1;
}
Replace with:
if ($sender_email != "" && !check_email($sender_email)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$error = 1;
}
if ($recipient_email != "") {
$recipient_email_temp = $recipient_email;
$recipient_email_temp = str_replace(" ", "", $recipient_email_temp);
$recipient_email_temp = str_replace(";", ",", $recipient_email_temp);
$recipient_email_array = explode(",", $recipient_email_temp);
$recipient_email_temp = $recipient_email;
$error_email = "";
foreach ($recipient_email_array as $key) {
if (check_email(trim($key))) {
$recipient_email_temp .= $key.", ";
}else{
$recipient_email_temp .= "<font style=\"background-color:red;\">".$key."</font>, ";
$error_email = 1;
}
}
if ($error_email) {
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format']." ( ".trim($recipient_email_temp,", ")." )";
$error = 1;
}
}else{
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$error = 1;
}
P.S. I'll move this thread to the MODs forum if we deside how "recipient name" should be handle, or if it's ok as it is now...