function pa_mail($to, $type, $array_of_data, $from = DEFAULT_SENDER) { global $path_prefix; global $network_info; global $base_url; $container_html = 'default_email_container.tpl'; if (empty($from)) { $from = DEFAULT_SENDER; } // getting email data ie subject and message for the specified type $type // here $array_of_data will be containing actual data to be replaced in subject and message frame $email_data = EmailMessages::get($type, $array_of_data); $subject = $email_data['subject']; $message = $email_data['message']; // patching up message and subject in the email container $email_container =& new Template($path_prefix . '/web/Themes/Beta/email_container/' . $container_html); $email_container->set('subject', $subject); $email_container->set('message', $message); // actual message to be sent through the mail $message = $email_container->fetch(); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=iso-8859-1\r\n" . "From: {$from}"; // if you want to test the e-mail system, set global // $mail_testing_callback to point to your own function, that // behaves like mail(). global $mail_testing_callback; $mail_func = $mail_testing_callback ? $mail_testing_callback : "mail"; $check = call_user_func($mail_func, $to, $subject, $message, $headers); if ($check == FALSE) { throw new PAException(MAIL_FUNCTION_FAILED, "Mail is not sent due to some internal server problem"); } else { return TRUE; } }
function pa_mail($to, $type, $array_of_data, $from = DEFAULT_SENDER) { global $default_sender; $container_html = 'default_email_container.tpl'; if (empty($from)) { $from = DEFAULT_SENDER; } // getting email data ie subject and message for the specified type $type // here $array_of_data will be containing actual data to be replaced in subject and message frame $email_data = EmailMessages::get($type, $array_of_data); $subject = $email_data['subject']; $message = $email_data['message']; // patching up message and subject in the email container $email_container = new Template('config/email_containers/' . $container_html); $email_container->set('subject', $subject); $email_container->set('message', $message); // actual message to be sent through the mail $body = $email_container->fetch(); //making the url relative. $body = str_replace(PA::$url . '/images', 'images', $body); //making the user picture or the other such files path relative. $body = str_replace(PA::$url . '/files', 'files', $body); $mail = new PHPMailer(); $body = eregi_replace("[\\]", '', $body); $subject = eregi_replace("[\\]", '', $subject); // $mail->Sender = DEFAULT_SENDER; $mail->From = $mail->FromName = $default_sender; $mail->Subject = $subject; $mail->AltBody = strip_tags($body); $mail->MsgHTML($body); $mail->AddAddress($to, $to); // echo "<pre>".print_r($mail,1)."</pre>"; if (!$mail->Send()) { // echo "<pre>".print_r($mail,1)."</pre>";exit; throw new CNException(MAIL_FUNCTION_FAILED, "Mail is not sent due to PHPMailer error: " . $mail->ErrorInfo); } else { return TRUE; } }
<?php global $path_prefix, $current_theme_path; $login_required = TRUE; $use_theme = 'Beta'; //TODO : Remove this when new UI is completely implemented. include "includes/page.php"; require_once "{$path_prefix}/ext/EmailMessages/EmailMessages.php"; require_once "{$path_prefix}/web/includes/default_email_messages.php"; // getting values from $_GET variable $email_type = !empty($_GET['email_type']) ? $_GET['email_type'] : NULL; $msg = NULL; // strip off unnecesary tags from posted values if ($email_type) { $email_data = EmailMessages::get($email_type); $subject = $email_data['subject']; $message = $email_data['message']; $configurable_variables = unserialize($email_data['configurable_variables']); } if (!empty($_POST['save_email'])) { filter_all_post($_POST); $mandatory_fields = array('subject' => 'Caption', 'email_message' => 'Message'); foreach ($mandatory_fields as $key => $value) { if (empty($_POST[$key])) { $error = TRUE; $msg[] = $value . ' can\'t be empty.'; } } if (!$error) { $email = new EmailMessages(); $email->subject = $_POST['subject'];
function switch_destination($destination) { $this->no_id = ""; if (empty($this->mail_type)) { $this->mail_type = ''; //none } if (empty($this->network_owner)) { // sometime group_owner param passed as recepient in this var - VERY BAD! $net_owner = new User(); $net_owner->load((int) PA::$network_info->owner_id); $this->network_owner = $net_owner->login_name; } // checking whether subject or message is set or not $msg_data = EmailMessages::get($this->mail_type, $this->mail_sub_msg_array); $this->subject = @$msg_data['subject']; $this->message = @$msg_data['message']; if (empty($this->subject)) { $this->subject = 'none'; } if (empty($this->message)) { $this->message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!'; } if ($this->mail_type == 'friend_request') { $mail_from = $_SESSION['user']['email']; } switch ($destination) { case NET_EMAIL: //external mail $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from); break; case NET_MSG: //internal messageing Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message); $sender = new User(); $sender->load((int) $this->from); $sender_id = $sender->user_id; $sender_name = $sender->login_name; $recipient_id = User::map_logins_to_ids($this->network_owner); $_sender_url = url_for('user_blog', array('login' => $sender->login_name)); $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>"; $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>'; $recipient_obj = new User(); foreach ($recipient_id as $key => $value) { $recipient_obj->load((int) $value); } // send msg waiting blink message $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name); auto_email_notification('msg_waiting', $params); break; case NET_BOTH: // via both option // FIXME: $mail_from seems not be set on peepagg try { $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from); } catch (PAEXception $e) { Logger::log(__FILE__ . ": pa_mail: " . $e->getMessage()); } Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message); $sender = new User(); $sender->load((int) $this->from); $sender_id = $sender->user_id; $sender_name = $sender->login_name; $recipient_id = User::map_logins_to_ids($this->network_owner); $_sender_url = url_for('user_blog', array('login' => $sender->login_name)); $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>"; $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>'; $recipient_obj = new User(); foreach ($recipient_id as $key => $value) { $recipient_obj->load((int) $value); } // send msg waiting blink message $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name); // chnaged by Martin: this is NET_BOTH, the user is already recieving it as email // so why do we also trigger the ms_waiting here? // auto_email_notification('msg_waiting', $params); break; } }
public function load($type) { $e_msg = EmailMessages::get($type); if (empty($this->subject)) { $this->subject = $e_msg['subject']; } if (empty($this->message)) { $this->message = $e_msg['message']; } if (empty($this->category)) { $this->message = $e_msg['category']; } if (empty($this->template)) { $this->message = $e_msg['template']; } if (empty($this->description)) { $this->description = $e_msg['description']; } if (empty($this->configurable_variables)) { $this->configurable_variables = $e_msg['configurable_variables']; } }
function switch_destination($destination) { global $to, $mail_type, $mail_sub_msg_array, $from, $no_id, $network_owner, $subject, $message, $config_site_name; // these should be instance vars, not globals! $no_id = ""; if (empty($mail_type)) { $mail_type = ''; //none } // checking whether subject or message is set or not $msg_data = EmailMessages::get($mail_type, $mail_sub_msg_array); $subject = $msg_data['subject']; $message = $msg_data['message']; if (empty($subject)) { $subject = 'none'; } if (empty($message)) { $message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!'; } if ($mail_type == 'friend_request') { $mail_from = $_SESSION['user']['email']; } switch ($destination) { case NET_EMAIL: //external mail $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from); break; case NET_MSG: //internal messageing Message::add_message($from, $no_id, $network_owner, $subject, $message); $sender = new User(); $sender->load((int) $from); $sender_id = $sender->user_id; $sender_name = $sender->login_name; $recipient_id = User::map_logins_to_ids($network_owner); $sender_url = url_for('user_blog', array('login' => $sender->login_name)); $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE; $recipient_obj = new User(); foreach ($recipient_id as $key => $value) { $recipient_obj->load((int) $value); } // send msg waiting blink message $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name); auto_email_notification('msg_waiting', $params); break; case NET_BOTH: // via both option // FIXME: $mail_from seems not be set on peepagg $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from); Message::add_message($from, $no_id, $network_owner, $subject, $message); $sender = new User(); $sender->load((int) $from); $sender_id = $sender->user_id; $sender_name = $sender->login_name; $recipient_id = User::map_logins_to_ids($network_owner); $sender_url = url_for('user_blog', array('login' => $sender->login_name)); $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE; $recipient_obj = new User(); foreach ($recipient_id as $key => $value) { $recipient_obj->load((int) $value); } // send msg waiting blink message $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name); auto_email_notification('msg_waiting', $params); break; } }