Author Topic: [MOD] Send postcard to more then one email address at ones  (Read 15999 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Send postcard to more then one email address at ones
« on: March 31, 2003, 12:48:13 AM »
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...:x. 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 ;)

Example

And finaly after all that boring overview here what u need to do:
1.
Open /postcards.php
Find:
Code: [Select]
 $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:
Code: [Select]
   $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:
Code: [Select]
 if (($sender_email != "" && !check_email($sender_email)) || ($recipient_email != "" && !check_email($recipient_email))) {
    $msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
    $error = 1;
  }
Replace with:
Code: [Select]
 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...;)
« Last Edit: May 03, 2005, 04:35:27 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline renicolay

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: [MOD] Send postcard to more then one email address at ones
« Reply #1 on: May 21, 2005, 04:26:11 AM »
Can this MOD work with multiple receipient names?  :)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Send postcard to more then one email address at ones
« Reply #2 on: May 21, 2005, 06:50:29 AM »
sorry, no
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline IWS_steffen

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • Kreuzfahrtschiffe gestern und heute
Re: [MOD] Send postcard to more then one email address at ones
« Reply #3 on: July 23, 2005, 08:36:23 PM »
Hallo V@no,

Ich habe leider kein Glück. Irgendwas mache ich falsch. Ich erhalte folgende Anzeige "Parse error: parse error, unexpected T_ELSE".

Da nur Änderungen an der postcard.php vorgenommen werden müssen, ist es vielleicht möglich die komplette postcard.php zu veröffentlichen?

Dank und grüsse aus Hamburg

Steffen

Offline IWS_steffen

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • Kreuzfahrtschiffe gestern und heute
Re: [MOD] Send postcard to more then one email address at ones
« Reply #4 on: September 20, 2005, 08:52:54 PM »
Hallo,

der MOD von V@ano ist natürlich OK. War mein Fehler. Sorry.


Offline tohave

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: [MOD] Send postcard to more then one email address at ones
« Reply #5 on: August 07, 2006, 10:41:40 PM »
Hi V@NO

I tried it but I got error on eCard. There is two small buttons apear on sent eCards (send and change originally). When I click on theme several times, I can get into the modification page of that eCard !

How can I delete those images at the buttom of sent eCards?

http://cardaz.birolmali.com/postcards.php?postcard_id=427cfd9e9fbaea6c6b645b091100cd6e

(10 days active)