function send_reminder($person) { global $ini; $toEmail = $person['email']; if (!empty($ini['OVERRIDE_RECIPIENT'])) { $toEmail = $ini['OVERRIDE_RECIPIENT']; } if (!strlen($person['email'])) { if (!empty($ini['VERBOSE'])) { echo $person['first_name'] . ' ' . $person['last_name'] . " has no email address - skipping \n"; } return; } $content = replace_keywords($ini['EMAIL_BODY'], $person); $html = nl2br($content); $message = Emailer::newMessage()->setSubject(replace_keywords($ini['SUBJECT'], $person))->setFrom(array($ini['FROM_ADDRESS'] => $ini['FROM_NAME']))->setTo(array($toEmail => $person['first_name'] . ' ' . $person['last_name']))->setBody($content)->addPart($html, 'text/html'); if (!empty($person['cc'])) { $cc_names = explode(';', $person['cc_name']); foreach (explode(';', $person['cc']) as $i => $cc) { if (!empty($ini['OVERRIDE_RECIPIENT'])) { $message->addCC($ini['OVERRIDE_RECIPIENT'], $cc_names[$i]); } else { $message->addCC($cc, $cc_names[$i]); } } } $res = Emailer::send($message); if (!$res) { echo "Failed to send to {$toEmail} \n"; } else { if (!empty($ini['VERBOSE'])) { echo "Sent reminder to " . $person['first_name'] . ' ' . $person['last_name']; if (!empty($person['cc'])) { echo " CC to " . $person['cc']; } echo "\n"; } } }
private function handleAccountRequest() { $person = $this->_findCandidateMember($_REQUEST['email']); require_once 'include/emailer.class.php'; $failureEmail = MEMBER_REGO_FAILURE_EMAIL; if (is_array($person)) { // Send them an email $hash = generate_random_string(32); $SQL = 'UPDATE _person SET resethash=' . $GLOBALS['db']->quote($hash) . ', resetexpires = NOW() + INTERVAL 24 HOUR WHERE id = ' . (int) $person['id']; $res = $GLOBALS['db']->exec($SQL); check_db_result($res); $url = BASE_URL . '/members/?email=' . rawurlencode($person['email']) . '&verify=' . rawurlencode($hash); $body = "Hi %s,\n\t\t\t\t\t\t\t\nTo activate your %s account, please %s\n\nIf you didn't request an account, you can just ignore this email"; $text = sprintf($body, $person['first_name'], SYSTEM_NAME, 'go to ' . $url); $html = sprintf(nl2br($body), $person['first_name'], SYSTEM_NAME, '<a href="' . $url . '">click here</a>.'); $message = Emailer::newMessage()->setSubject(MEMBER_REGO_EMAIL_SUBJECT)->setFrom(array(MEMBER_REGO_EMAIL_FROM_ADDRESS => MEMBER_REGO_EMAIL_FROM_NAME))->setTo(array($person['email'] => $person['first_name'] . ' ' . $person['last_name']))->setBody($body)->addPart($html, 'text/html'); $res = Emailer::send($message); if (TRUE == $res) { require_once 'templates/account_request_received.template.php'; exit; } else { $this->_error = 'Could not send to the specified address. Your email server may be experiencing problems.'; return; } } else { if (!Emailer::validateAddress($_REQUEST['email'])) { $this->_error = 'You have entered an invalid email address. Please check the address and try again.'; } else { if ($person == -1 && !empty($failureEmail)) { // This email address is in use by two or more persons from *different families*. // Therefore this address cannot be used for member access. $message = Emailer::newMessage()->setSubject("Member Account request from multi-family email")->setFrom(array(MEMBER_REGO_EMAIL_FROM_ADDRESS => SYSTEM_NAME . ' Jethro System'))->setTo(MEMBER_REGO_FAILURE_EMAIL)->setBody("Hi, \n\nThis is an automated message from the Jethro system at " . BASE_URL . ".\n\n" . "Somebody has used the form at " . BASE_URL . "/members to request member-access to this Jethro system. \n\n" . "The email address they specified was " . $_REQUEST['email'] . " but this address belongs to SEVERAL persons from DIFFERENT families. It therefore can't be used for member access.\n\n" . "Please look up this email address in Jethro and contact the relevant persons to help them solve this problem.\n\n"); $res = Emailer::send($message); // Show the user the generic "thanks" page - because we do not want // to tell strangers whether an email is or isn't known. require_once 'templates/account_request_received.template.php'; exit; } else { if (!empty($failureEmail)) { // This email address doesn't match any person record. // Send the administrator an email $message = Emailer::newMessage()->setSubject("Member Account request from unknown email")->setFrom(array(MEMBER_REGO_EMAIL_FROM_ADDRESS => SYSTEM_NAME . ' Jethro System'))->setTo(MEMBER_REGO_FAILURE_EMAIL)->setBody("Hi, \n\nThis is an automated message from the Jethro system at " . BASE_URL . ".\n\n" . "Somebody has used the form at " . BASE_URL . "/members to request member-access to this Jethro system. \n\n" . "The email address they specified was " . $_REQUEST['email'] . " but there is no current person record in the Jethro system with that address. (There could be an archived record).\n\n" . "If you believe this person is a church member, please add their email address to their person record and then ask them to try registering again.\n\n"); $res = Emailer::send($message); // Show the user the generic "thanks" page - because we do not want // to tell strangers whether an email is or isn't known. require_once 'templates/account_request_received.template.php'; exit; } } } } }