本文整理汇总了PHP中Zend_Mail::clearFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail::clearFrom方法的具体用法?PHP Zend_Mail::clearFrom怎么用?PHP Zend_Mail::clearFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mail
的用法示例。
在下文中一共展示了Zend_Mail::clearFrom方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grade_below_threshold_notice
function grade_below_threshold_notice($assessment_list)
{
global $db, $AGENT_CONTACTS;
$assessment_list = (array) $assessment_list;
foreach ($assessment_list as $assessment_id => $assessment) {
$mail = new Zend_Mail();
$mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]);
$mail->addHeader("X-Section", "Gradebook Notification System", true);
$mail->clearFrom();
$mail->clearSubject();
$mail->setFrom($AGENT_CONTACTS["agent-notifications"]["email"], APPLICATION_NAME . ' Gradebook System');
$mail->setSubject("Grade Below Threshold Notification");
$message = "<pre>This notification is being sent to inform you that students scored below the assessment threshold.\n\n";
$message .= "Course:\t\t\t" . $assessment["course_name"] . " - " . $assessment["course_code"] . "\n";
$message .= "Assessment:\t\t<a href=\"" . ENTRADA_URL . "/admin/gradebook/assessments?section=grade&id=" . $assessment["course_id"] . "&assessment_id=" . $assessment_id . "\">" . $assessment["assessment_name"] . "</a>\n";
$message .= "Assessment ID:\t\t" . $assessment_id . "\n";
$message .= "Grade Threshold:\t" . $assessment["threshold"] . "%\n\n";
$message .= "The following students scored below the assessment threshold:\n";
$message .= "-------------------------------------------------------------\n\n";
foreach ($assessment["students"] as $proxy_number => $student) {
$query = "\tUPDATE `assessment_grades`\n\t\t\t\t\t\tSET `threshold_notified` = '1'\n\t\t\t\t\t\tWHERE `grade_id` = " . $db->qstr($student["grade_id"]);
$result = $db->Execute($query);
$message .= "Student:\t\t" . $student["student_name"] . " - [" . $student["student_email"] . "] \n";
$message .= "Student Number:\t\t" . $student["student_number"] . "\n";
$message .= "Grade Recieved:\t\t" . $student["assessment_grade"] . "%\n\n";
}
$message .= "</pre>";
$mail->setBodyHtml($message);
$query = "\tSELECT a.`contact_type`, a.`contact_order`, b.`prefix`, b.`firstname`, b.`lastname`, b.`email`, a.`proxy_id`\n\t\t\tFROM " . DATABASE_NAME . ".`course_contacts` AS a \n\t\t\tJOIN " . AUTH_DATABASE . ".`user_data` AS b \n\t\t\tON a.`proxy_id` = b.`id` \n\t\t\tWHERE a.`course_id` = " . $db->qstr($assessment["course_id"]) . "\n\t\t\tORDER BY a.`contact_type` DESC, a.`contact_order` ASC";
$contacts = $db->GetAll($query);
foreach ($contacts as $contact) {
$mail->addTo($contact["email"], (!empty($contact["prefix"]) ? $contact["prefix"] . " " : "") . $contact["firstname"] . " " . $contact["lastname"]);
$contact_proxies[] = $contact["proxy_id"];
}
$sent = true;
try {
$mail->send();
} catch (Exception $e) {
$sent = false;
}
if ($sent) {
application_log("success", "Sent grade below threshold notification to Program Coordinators / Directors [" . implode(",", $contact_proxies) . "].");
$return_value = true;
} else {
application_log("error", "Unable to send grade below threshold notification to Program Coordinators / Directors [" . implode(",", $contact_proxies) . "].");
}
}
}
示例2: _setMailFrom
/**
* set from in mail to be sent
*
* @param Tinebase_Mail $_mail
* @param Felamimail_Model_Account $_account
* @param Felamimail_Model_Message $_message
*/
protected function _setMailFrom(Zend_Mail $_mail, Felamimail_Model_Account $_account, Felamimail_Model_Message $_message = NULL)
{
$_mail->clearFrom();
$from = isset($_account->from) && !empty($_account->from) ? $_account->from : Tinebase_Core::getUser()->accountFullName;
$email = $_message !== NULL && !empty($_message->from_email) ? $_message->from_email : $_account->email;
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Set from for mail: ' . $email . ' / ' . $from);
}
$_mail->setFrom($email, $from);
}
示例3: _setMailFrom
/**
* set from in mail to be sent
*
* @param Expressomail_mail $_mail
* @param Expressomail_Model_Account $_account
* @param Expressomail_Model_Message $_message
*/
protected function _setMailFrom(Zend_Mail $_mail, Expressomail_Model_Account $_account, Expressomail_Model_Message $_message = NULL)
{
$_mail->clearFrom();
$from = isset($_account->from) && !empty($_account->from) ? $_account->from : Tinebase_Core::getUser()->accountFullName;
isset($_message->from_name) ? $from = $_message->from_name : ($from = $from);
$user = Tinebase_Core::getUser();
try {
$allowedEmails = Expressomail_Session::getSessionNamespace()->allowedEmails[$user->accountId];
} catch (Zend_Session_Exception $zse) {
Tinebase_Core::getLogger()->warn(__METHOD__ . "::" . __LINE__ . ":: It was not possible to get Expressomail Session Namespace");
$allowedEmails = array($user->accountEmailAddress);
}
$email = $_message !== NULL && !empty($_message->from_email) ? $_message->from_email : $_account->email;
if (array_search($email, $allowedEmails) === FALSE) {
throw new Tinebase_Exception_Record_NotAllowed('You Can\'t send a email with this FROM address: ' . $email);
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . 'User with id: ' . $user->accountId . 'tried to send email with address not allowed: ' . $email);
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Set from for mail: ' . $email . ' / ' . $from);
}
$_mail->setFrom($email, $from);
}
示例4: clearFrom
/**
* Clears the sender from the mail
*
* @return Zend_Mail Provides fluent interface
*/
public function clearFrom()
{
$this->_fromName = null;
return parent::clearFrom();
}
示例5: array
* @author Developer: Don Zuiker <don.zuiker@queensu.ca>
* @copyright Copyright 2013 Queen's Univerity. All Rights Reserved.
* if they're doing a clerkship rotation in a location that the regional education manages (oshawa)
*/
@set_time_limit(0);
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
* Include the Entrada init code.
*/
require_once "init.inc.php";
$search = array("%LEARNER_NAME%");
$mail = new Zend_Mail();
//Department id for Regional Education is 170.
$query = "\tSELECT c.`username`,\n\t\t\t\tCONCAT_WS(' ', c.`firstname`, c.`lastname`) AS `fullname`,\n\t\t\t\tc.`email`,\n\t\t\t\ta.`apartment_id`,\n\t\t\t\ta.`apartment_title`,\n\t\t\t\ta.`apartment_number`,\n\t\t\t\ta.`apartment_address`,\n\t\t\t\td.`region_name`,\n\t\t\t\ta.`apartment_province`,\n\t\t\t\tb.`aschedule_id`,\n\t\t\t\t170 as `department_id`,\n\t\t\t\tFROM_UNIXTIME(b.inhabiting_start) AS inhabiting_start,\n\t\t\t\tFROM_UNIXTIME(b.inhabiting_finish) AS inhabiting_finish\n\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`apartments` AS a\n\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`apartment_schedule` AS b\n\t\t\tON a.`apartment_id` = b.`apartment_id`\n\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` as c\n\t\t\tON b.`proxy_id` = c.`id`\n\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`regions` as d\n\t\t\tON a.`region_id` = d.`region_id`\n\t\t\tWHERE b.`occupant_title` = ''\t\n\t\t\tAND a.`department_id` = 170\n\t\t\tAND DATEDIFF(FROM_UNIXTIME(b.`inhabiting_finish`), FROM_UNIXTIME('" . time() . "')) = 7";
$occupants = $db->GetAll($query);
if ($occupants) {
foreach ($occupants as $occupant) {
$email_body = file_get_contents(ENTRADA_ABSOLUTE . "/templates/" . $ENTRADA_TEMPLATE->activeTemplate() . "/email/regionaled-learner-predeparture-notification.txt");
$mail->addHeader("X-Section", "Regional Education Notification System", true);
$mail->setFrom($AGENT_CONTACTS["agent-regionaled"][$occupant["department_id"]]["email"], $AGENT_CONTACTS["agent-regionaled"][$occupant["department_id"]]["name"]);
$mail->clearSubject();
$mail->setSubject("Regional Accomodation: " . $occupant["region_name"]);
$replace = array($occupant["fullname"]);
$mail->setBodyText(str_replace($search, $replace, $email_body));
$mail->clearRecipients();
$mail->addTo($occupant["email"], $occupant["fullname"]);
$mail->send();
//clean up
$mail->clearFrom();
}
}
示例6: notify_regional_education
//.........这里部分代码省略.........
break;
case "change-critical":
$message = "Attention " . $AGENT_CONTACTS["agent-regionaled"]["name"] . ",\n\n";
$message .= $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"] . " has updated an event in " . $whole_name . "'s ";
$message .= "clerkship schedule, to which you had previously assigned housing. This update involves a change to the region or the ";
$message .= "dates that the event took place in. Due to this critical change taking place, the housing for this event for this ";
$message .= "student has been removed.\n\n";
if ($result["manage_apartments"]) {
$message .= "Please log into the clerkship system and re-assign housing to this student for this event.\n\n";
} else {
$message .= "Since this event no longer is taking place in a region which is managed by Regional Education, \n";
$message .= "no further action is required on your part in the system.\n\n";
}
$message .= "Information For Reference:\n\n";
$message .= "OLD Event Information:\n";
$message .= "Event Title:\t" . $event_info["event_title"] . "\n";
$message .= "Region:\t\t" . get_region_name($event_info["region_id"]) . "\n";
$message .= "Start Date:\t" . date(DEFAULT_DATE_FORMAT, $event_info["event_start"]) . "\n";
$message .= "Finish Date:\t" . date(DEFAULT_DATE_FORMAT, $event_info["event_finish"]) . "\n\n";
$message .= "NEW Event Information:\n";
$message .= "Event Title:\t" . html_decode($result["event_title"]) . "\n";
$message .= "Region:\t\t" . $result["region_name"] . "\n";
$message .= "Start Date:\t" . date(DEFAULT_DATE_FORMAT, $result["event_start"]) . "\n";
$message .= "Finish Date:\t" . date(DEFAULT_DATE_FORMAT, $result["event_finish"]) . "\n\n";
if ($apartments && ($assigned_apartments = @count($apartments))) {
$message .= "Apartment" . ($assigned_apartments != 1 ? "s" : "") . " " . $whole_name . " was removed from:\n";
foreach ($apartments as $apartment) {
$message .= "Apartment Title:\t" . $apartment["apartment_title"] . "\n";
$message .= "Inhabiting Start:\t" . date(DEFAULT_DATE_FORMAT, $apartment["inhabiting_start"]) . "\n";
$message .= "Inhabiting Finish:\t" . date(DEFAULT_DATE_FORMAT, $apartment["inhabiting_finish"]) . "\n\n";
}
}
$message .= "=======================================================\n\n";
$message .= "Deletion Date:\t" . date("r", time()) . "\n";
$message .= "Deleted By:\t" . $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"] . " (" . $ENTRADA_USER->getID() . ")\n";
break;
case "change-non-critical":
case "updated":
default:
$message = "Attention " . $AGENT_CONTACTS["agent-regionaled"]["name"] . ",\n\n";
$message .= $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"] . " has updated an event in " . $whole_name . "'s ";
$message .= "clerkship schedule, to which you had previously assigned housing.\n\n";
$message .= "Important:\n";
$message .= "This update does not affect the date or region of this event, as such this change is considered non-critical ";
$message .= "and no action is required on your part.\n\n";
$message .= "Information For Reference:\n\n";
$message .= "OLD Event Information:\n";
$message .= "Event Title:\t" . $event_info["event_title"] . "\n";
$message .= "Region:\t\t" . get_region_name($event_info["region_id"]) . "\n";
$message .= "Start Date:\t" . date(DEFAULT_DATE_FORMAT, $event_info["event_start"]) . "\n";
$message .= "Finish Date:\t" . date(DEFAULT_DATE_FORMAT, $event_info["event_finish"]) . "\n\n";
$message .= "NEW Event Information:\n";
$message .= "Event Title:\t" . html_decode($result["event_title"]) . "\n";
$message .= "Region:\t\t" . $result["region_name"] . "\n";
$message .= "Start Date:\t" . date(DEFAULT_DATE_FORMAT, $result["event_start"]) . "\n";
$message .= "Finish Date:\t" . date(DEFAULT_DATE_FORMAT, $result["event_finish"]) . "\n\n";
if ($apartments && ($assigned_apartments = @count($apartments))) {
$message .= "Apartment" . ($assigned_apartments != 1 ? "s" : "") . " " . $whole_name . " is assigned to:\n";
foreach ($apartments as $apartment) {
$message .= "Apartment Title:\t" . $apartment["apartment_title"] . "\n";
$message .= "Inhabiting Start:\t" . date(DEFAULT_DATE_FORMAT, $apartment["inhabiting_start"]) . "\n";
$message .= "Inhabiting Finish:\t" . date(DEFAULT_DATE_FORMAT, $apartment["inhabiting_finish"]) . "\n\n";
}
}
$message .= "=======================================================\n\n";
$message .= "Updated Date:\t" . date("r", time()) . "\n";
$message .= "Update By:\t" . $_SESSION["details"]["firstname"] . " " . $_SESSION["details"]["lastname"] . " (" . $ENTRADA_USER->getID() . ")\n";
break;
}
$mail = new Zend_Mail();
$mail->addHeader("X-Originating-IP", $_SERVER["REMOTE_ADDR"]);
$mail->addHeader("X-Section", "Clerkship Notify System", true);
$mail->clearFrom();
$mail->clearSubject();
$mail->setFrom($AGENT_CONTACTS["agent-notifications"]["email"], APPLICATION_NAME . ' Clerkship System');
$mail->setSubject("MEdTech Clerkship System - " . ucwords($action) . " Event");
$mail->setBodyText($message);
$mail->clearRecipients();
$mail->addTo($AGENT_CONTACTS["agent-regionaled"]["email"], $AGENT_CONTACTS["agent-regionaled"]["name"]);
$sent = true;
try {
$mail->send();
application_log("success", "An event change notification has been sent to regional education to notify them of the changes to the event [" . $event_info["event_id"] . "] which will affect the apartment schedule.");
return true;
} catch (Exception $e) {
system_log_data("error", "Unable to send " . $action . " notification to regional education. Zend_mail said: " . $e->getMessage());
return false;
}
} else {
return true;
}
} else {
// No need to notify Regional Education because the event is already over, just return true.
return true;
}
} else {
system_log_data("error", "The notify_regional_education() function returned false with no results from the database query. Database said: " . $db->ErrorMsg());
return false;
}
}
示例7: sendToRole
/**
* Send email to all users who have the same role
*
* @param Core_Models_Role $role
* @param Mail_Models_Template $template
*/
public static function sendToRole($role, $template)
{
$criteria = $role->role_id == '' ? array('status' => 1) : array('role' => $role->role_id, 'status' => 1);
$users = Core_Services_User::find(null, null, $criteria);
/**
* Get mail transport instance
*/
$transport = self::getMailTransport();
/**
* Send email to each user
* @see http://framework.zend.com/manual/en/zend.mail.multiple-emails.html
*/
$search = array(Mail_Models_Mail::MAIL_VARIABLE_EMAIL, Mail_Models_Mail::MAIL_VARIABLE_USERNAME);
foreach ($users as $u) {
$replace = array($u->email, $u->user_name);
$subject = str_replace($search, $replace, $template->subject);
$content = str_replace($search, $replace, $template->content);
$mail = new Mail_Models_Mail(array('template_id' => $template->template_id, 'subject' => $subject, 'content' => $content, 'created_user_id' => $user->user_id, 'from_mail' => $template->from_mail, 'from_name' => $template->from_name, 'reply_to_mail' => $template->reply_to_mail, 'reply_to_name' => $template->reply_to_name, 'to_mail' => $u->email, 'to_name' => $u->user_name, 'status' => 'sent', 'created_date' => date('Y-m-d H:i:s'), 'sent_date' => date('Y-m-d H:i:s')));
Mail_Services_Mail::add($mail);
$sender = new Zend_Mail();
$sender->clearFrom()->setFrom($template->from_mail, $template->from_name)->clearReplyTo()->setReplyTo($template->reply_to_mail, $template->reply_to_name)->addTo($u->email, $u->user_name)->setSubject($subject)->setBodyHtml($content)->send($transport);
}
}