$email_text = str_replace('{{NON_MEMBER_LANGUAGE}}', $non_membr_lang, $email_text); } // parse name placeholder $email_html = str_replace('{{NAME}}', $email_to_name, $email_html); $email_text = str_replace('{{NAME}}', $email_to_name, $email_text); // parse invite URL placeholder $email_html = str_replace('{{INVITE_URL}}', $invitation_url, $email_html); $email_text = str_replace('{{INVITE_URL}}', $invitation_url, $email_text); // parse non-member language placeholder $email_html = str_replace('{{NON_MEMBER_LANGUAGE}}', '', $email_html); $email_text = str_replace('{{NON_MEMBER_LANGUAGE}}', '', $email_text); // send the email $result[] = mandrill_sendmail($email_html, $email_text, $email_subject, $email_to_address, $email_to_name, $email_tags); // if an exception was thrown, notify admin if ($result[0]['mandrill_error']) { qb_notify_admin_mandrill_error($result[0]['mandrill_error'], $emails, $email_to_address, $board_id); break; } } else { // TO DO: optional: return a different status indicating invitations are pending. For now, we just return "sent" to keep things simple. //$result[] = 'already-sent'; $result[0][0] = array('status' => 'sent'); } } } // return result for jQuery goodness echo json_encode(array('result' => $result)); exit; /* * This function loads the master template and replaces the * placeholder values with text specific to a board invitation.
/* * Send welcome email via Mandrill API */ // load up Mandrill dependencies require_once 'mandrill/send.php'; $email_html = qb_build_email_html($first_name, $user_email); $email_text = qb_build_email_text($first_name, $user_email); $email_subject = 'Welcome to Quoteboard'; $email_to_address = $user_email; $email_to_name = $full_name; $email_tags = array('welcome', 'welcome-facebook'); // send the email $result[] = mandrill_sendmail($email_html, $email_text, $email_subject, $email_to_address, $email_to_name, $email_tags); // if an exception was thrown, notify admin if ($result[0]['mandrill_error']) { qb_notify_admin_mandrill_error($result[0]['mandrill_error'], $email_to_address); } // finish registration require TEMPLATEPATH . '/includes/register-finish.php'; } else { echo json_encode(array('result' => false, 'errors' => 'There was a problem completing your registration: ' . $new_user_id->get_error_message())); } /* * This function loads the master template and replaces the * placeholder values with text specific to a new user registration. */ function qb_build_email_html($first_name, $user_email) { $email_header = "Welcome!"; $email_body = ' <p>' . $first_name . ',</p>