本文整理汇总了PHP中Horde_Mime_Part::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::send方法的具体用法?PHP Horde_Mime_Part::send怎么用?PHP Horde_Mime_Part::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::send方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyIdentity
/**
* Sends a message to an email address supposed to be added to the
* identity.
*
* A message is send to this address containing a time-sensitive link to
* confirm that the address really belongs to that user.
*
* @param integer $id The identity's ID.
* @param string $old_addr The old From: address.
*
* @throws Horde_Mime_Exception
*/
public function verifyIdentity($id, $old_addr)
{
global $injector, $notification, $registry;
$hash = strval(new Horde_Support_Randomid());
$pref = $this->_confirmEmail();
$pref[$hash] = $this->get($id);
$pref[$hash][self::EXPIRE] = time() + self::EXPIRE_SECS;
$this->_confirmEmail($pref);
$new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
$confirm = Horde::url($registry->getServiceLink('emailconfirm')->add('h', $hash)->setRaw(true), true);
$message = sprintf(Horde_Core_Translation::t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."), $new_addr, $confirm);
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
$msg_headers->addHeaderOb(Horde_Mime_Headers_UserAgent::create());
$msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
$msg_headers->addHeader('To', $new_addr);
$msg_headers->addHeader('From', $old_addr);
$msg_headers->addHeader('Subject', Horde_Core_Translation::t("Confirm new email address"));
$body = new Horde_Mime_Part();
$body->setType('text/plain');
$body->setContents(Horde_String::wrap($message, 76));
$body->setCharset('UTF-8');
$body->send($new_addr, $msg_headers, $injector->getInstance('Horde_Mail'));
$notification->push(sprintf(Horde_Core_Translation::t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
}
示例2: _handle
//.........这里部分代码省略.........
$notification->push(_("This action is not supported."), 'horde.warning');
}
break;
case 'vJournal':
default:
$notification->push(_("This action is not supported."), 'horde.warning');
}
if ($action == 'import') {
break;
}
// Fall-through for 'accept-import'
// Fall-through for 'accept-import'
case 'accept':
case 'deny':
case 'tentative':
// vEvent request.
if (isset($components[$key]) && $components[$key]->getType() == 'vEvent') {
$vEvent = $components[$key];
$resource = new Horde_Itip_Resource_Identity($injector->getInstance('IMP_Identity'), $vEvent->getAttribute('ATTENDEE'), $vars->identity);
switch ($action) {
case 'accept':
case 'accept-import':
$type = new Horde_Itip_Response_Type_Accept($resource);
break;
case 'deny':
$type = new Horde_Itip_Response_Type_Decline($resource);
break;
case 'tentative':
$type = new Horde_Itip_Response_Type_Tentative($resource);
break;
}
try {
// Send the reply.
Horde_Itip::factory($vEvent, $resource)->sendMultiPartResponse($type, new Horde_Core_Itip_Response_Options_Horde('UTF-8', array()), $injector->getInstance('IMP_Mail'));
$notification->push(_("Reply Sent."), 'horde.success');
$result = true;
} catch (Horde_Itip_Exception $e) {
$notification->push(sprintf(_("Error sending reply: %s."), $e->getMessage()), 'horde.error');
}
} else {
$notification->push(_("This action is not supported."), 'horde.warning');
}
break;
case 'send':
case 'reply':
case 'reply2m':
// vfreebusy request.
if (isset($components[$key]) && $components[$key]->getType() == 'vFreebusy') {
$vFb = $components[$key];
// Get the organizer details.
try {
$organizer = parse_url($vFb->getAttribute('ORGANIZER'));
} catch (Horde_Icalendar_Exception $e) {
break;
}
$organizerEmail = $organizer['path'];
$organizer = $vFb->getAttribute('ORGANIZER', true);
$organizerFullEmail = new Horde_Mail_Rfc822_Address($organizerEmail);
if (isset($organizer['cn'])) {
$organizerFullEmail->personal = $organizer['cn'];
}
if ($action == 'reply2m') {
$startStamp = time();
$endStamp = $startStamp + 60 * 24 * 3600;
} else {
try {
示例3: generate
/**
* Generate the MDN according to the specifications listed in RFC
* 3798 [3].
*
* @param boolean $action Was this MDN type a result of a manual
* action on part of the user?
* @param boolean $sending Was this MDN sent as a result of a manual
* action on part of the user?
* @param string $type The type of action performed by the user.
* Per RFC 3798 [3.2.6.2] the following types are
* valid:
* - deleted
* - displayed
* @param string $name The name of the local server.
* @param Horde_Mail_Transport $mailer Mail transport object.
* @param array $opts Additional options:
* - charset: (string) Default charset.
* DEFAULT: NONE
* - from_addr: (string) From address.
* DEFAULT: NONE
* @param array $mod The list of modifications. Per RFC 3798
* [3.2.6.3] the following modifications are
* valid:
* - error
* @param array $err If $mod is 'error', the additional
* information to provide. Key is the type of
* modification, value is the text.
*/
public function generate($action, $sending, $type, $name, $mailer, array $opts = array(), array $mod = array(), array $err = array())
{
$opts = array_merge(array('charset' => null, 'from_addr' => null), $opts);
if (!($hdr = $this->_headers[self::MDN_HEADER])) {
throw new RuntimeException('Need at least one address to send MDN to.');
}
$to = $hdr->getAddressList(true);
$ua = Horde_Mime_Headers_UserAgent::create();
if ($orig_recip = $this->_headers['Original-Recipient']) {
$orig_recip = $orig_recip->value_single;
}
/* Set up the mail headers. */
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
$msg_headers->addHeaderOb($ua);
/* RFC 3834 [5.2] */
$msg_headers->addHeader('Auto-Submitted', 'auto-replied');
$msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
if ($opts['from_addr']) {
$msg_headers->addHeader('From', $opts['from_addr']);
}
$msg_headers->addHeader('To', $to);
$msg_headers->addHeader('Subject', Horde_Mime_Translation::t("Disposition Notification"));
/* MDNs are a subtype of 'multipart/report'. */
$msg = new Horde_Mime_Part();
$msg->setType('multipart/report');
$msg->setContentTypeParameter('report-type', 'disposition-notification');
/* The first part is a human readable message. */
$part_one = new Horde_Mime_Part();
$part_one->setType('text/plain');
$part_one->setCharset($opts['charset']);
if ($type == 'displayed') {
$contents = sprintf(Horde_Mime_Translation::t("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers['Date'], $this->_headers['To'], $this->_headers['Subject']);
$flowed = new Horde_Text_Flowed($contents, $opts['charset']);
$flowed->setDelSp(true);
$part_one->setContentTypeParameter('format', 'flowed');
$part_one->setContentTypeParameter('DelSp', 'Yes');
$part_one->setContents($flowed->toFlowed());
}
// TODO: Messages for other notification types.
$msg[] = $part_one;
/* The second part is a machine-parseable description. */
$part_two = new Horde_Mime_Part();
$part_two->setType('message/disposition-notification');
$part_two_h = new Horde_Mime_Headers();
$part_two_h->addHeader('Reporting-UA', $name . '; ' . $ua);
if (!empty($orig_recip)) {
$part_two_h->addHeader('Original-Recipient', 'rfc822;' . $orig_recip);
}
if ($opts['from_addr']) {
$part_two_h->addHeader('Final-Recipient', 'rfc822;' . $opts['from_addr']);
}
if ($msg_id = $this->_headers['Message-ID']) {
$part_two_h->addHeader('Original-Message-ID', strval($msg_id));
}
/* Create the Disposition field now (RFC 3798 [3.2.6]). */
$dispo = ($action ? 'manual-action' : 'automatic-action') . '/' . ($sending ? 'MDN-sent-manually' : 'MDN-sent-automatically') . '; ' . $type;
if (!empty($mod)) {
$dispo .= '/' . implode(', ', $mod);
}
$part_two_h->addHeader('Disposition', $dispo);
if (in_array('error', $mod) && isset($err['error'])) {
$part_two_h->addHeader('Error', $err['error']);
}
$part_two->setContents(trim($part_two_h->toString()) . "\n");
$msg[] = $part_two;
/* The third part is the text of the original message. RFC 3798 [3]
* allows us to return only a portion of the entire message - this
* is left up to the user. */
$part_three = new Horde_Mime_Part();
$part_three->setType('message/rfc822');
$part_three_text = array(trim($this->_headers->toString()) . "\n");
//.........这里部分代码省略.........
示例4: sendNotification
/**
* Send notification to attachment owner.
*/
public function sendNotification()
{
global $conf, $injector, $registry;
if (empty($conf['compose']['link_attachments_notify'])) {
return;
}
try {
$identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($this->_user);
$address = $identity->getDefaultFromAddress();
/* Ignore missing addresses, which are returned as <>. */
if (strlen($address) < 3 || $this->_getDeleteToken()) {
return;
}
$address_full = $identity->getDefaultFromAddress(true);
/* Load user prefs to correctly translate gettext strings. */
if (!$registry->getAuth()) {
$prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('imp', array('user' => $this->_user));
$registry->setLanguageEnvironment($prefs->getValue('language'));
}
$h = new Horde_Mime_Headers();
$h->addReceivedHeader(array('dns' => $injector->getInstance('Net_DNS2_Resolver'), 'server' => $conf['server']['name']));
$h->addMessageIdHeader();
$h->addUserAgentHeader();
$h->addHeader('Date', date('r'));
$h->addHeader('From', $address_full);
$h->addHeader('To', $address_full);
$h->addHeader('Subject', _("Notification: Linked attachment downloaded"));
$h->addHeader('Auto-Submitted', 'auto-generated');
$msg = new Horde_Mime_Part();
$msg->setType('text/plain');
$msg->setCharset('UTF-8');
$md = $this->_atc->getMetadata();
$msg->setContents(Horde_String::wrap(_("Your linked attachment has been downloaded by at least one user.") . "\n\n" . sprintf(_("Name: %s"), $md->filename) . "\n" . sprintf(_("Type: %s"), $md->type) . "\n" . sprintf(_("Sent Date: %s"), date('r', $md->time)) . "\n\n" . _("Click on the following link to permanently delete the attachment:") . "\n" . strval($this->_atc->link_url->add('d', $this->_getDeleteToken(true)))));
$msg->send($address, $h, $injector->getInstance('Horde_Mail'));
} catch (Exception $e) {
Horde::log($e, 'ERR');
}
}
示例5: testBug13709
public function testBug13709()
{
$p_part = new Horde_Mime_Part();
$p_part->setType('text/plain');
$p_part->setContents('Foo bär');
$h_part = new Horde_Mime_Part();
$h_part->setType('text/html');
$h_part->setContents('Foo<br />
<br />
"smith, Jane (IAM)" <<a href="mailto:Jane.smith@kit.edu">Jane.smith@kit.edu</a>> wrote:<br />
<br />
<blockquote type="cite" style="border-left:2px solid blue;margin-left:2px;padding-left:12px;"><html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hallo Jörk,<div><br></div><div>hoffe es geht dir gut und bei HHHH ist alles okay?</div><div><br></div><div>Ich wollte gerade auf die XXX III Homepage schauen und haben im Browser nur <a href="http://example.com">example.com</a> eingegeben.</div><div>Damit bin ich auf einer Seite mit XXX II - Logo gelandet, die sofort Passwort und Nutzername abgefragt hat.</div><div>Ist diese Seite auch von Euch?</div><div><br></div><div>Liebe Grüße,</div><div>Jane</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div>
<div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">--------------------------------------------------<br>Dr. Jane smith</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">( geb. Repper)<br>Karlsruhe Institute of Technology (KIT) <br>IAM-WK@INT <br>Hermann-von-Helmholtz-Platz 1, Building 640, </div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">76344 Eggenstein-Leopoldshafen, Germany<br><br>Phone CN: +49 721 608-26960</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 10px;">Phone CS: +49 721 608-47447<br>Web: <a href="http://www.kit.edu/">http://www.kit.edu/</a> <br><br>KIT – University of the State of Baden-Wuerttemberg and<br>National Research Center of the Helmholtz Association</div></div>
</div>
<br></div></body></html></blockquote><br /><br />');
$base_part = new Horde_Mime_Part();
$base_part->setType('multipart/alternative');
$base_part[] = $p_part;
$base_part[] = $h_part;
$headers = $base_part->addMimeHeaders();
$headers->addHeader('From', 'sender@example.com');
$headers->addHeader('Subject', 'My Subject');
$mailer = new Horde_Mail_Transport_Mock();
$base_part->send('recipient@example.com', $headers, $mailer, array('encode' => Horde_Mime_Part::ENCODE_8BIT));
$sent = current($mailer->sentMessages);
$sent_mime = Horde_Mime_Part::parseMessage($sent['header_text'] . "\n\n" . $sent['body']);
$headers = Horde_Mime_Headers::parseHeaders($sent_mime[$sent_mime->findBody('plain')]->toString(array('headers' => true, 'encode' => Horde_Mime_Part::ENCODE_8BIT)));
$this->assertEquals('8bit', $headers->getHeader('Content-Transfer-Encoding')->value_single);
$headers = Horde_Mime_Headers::parseHeaders($sent_mime[$sent_mime->findBody('html')]->toString(array('headers' => true, 'encode' => Horde_Mime_Part::ENCODE_8BIT)));
$this->assertEquals('quoted-printable', $headers->getHeader('Content-Transfer-Encoding'));
}
示例6: generate
/**
* Generate the MDN according to the specifications listed in RFC
* 3798 [3].
*
* @param boolean $action Was this MDN type a result of a manual
* action on part of the user?
* @param boolean $sending Was this MDN sent as a result of a manual
* action on part of the user?
* @param string $type The type of action performed by the user.
* Per RFC 3798 [3.2.6.2] the following types are
* valid:
* - deleted
* - displayed
* @param string $name The name of the local server.
* @param Mail $mailer A Mail driver.
* @param array $opts Additional options:
* - charset: (string) Default charset.
* DEFAULT: NONE
* - from_addr: (string) From address.
* DEFAULT: NONE
* @param array $mod The list of modifications. Per RFC 3798
* [3.2.6.3] the following modifications are
* valid:
* - error
* @param array $err If $mod is 'error', the additional
* information to provide. Key is the type of
* modification, value is the text.
*
* @throws Horde_Mime_Exception
*/
public function generate($action, $sending, $type, $name, $mailer, array $opts = array(), array $mod = array(), array $err = array())
{
$opts = array_merge(array('charset' => null, 'from_addr' => null), $opts);
$to = $this->getMdnReturnAddr();
$ua = $this->_headers->getUserAgent();
$orig_recip = $this->_headers->getValue('Original-Recipient');
if (!empty($orig_recip) && is_array($orig_recip)) {
$orig_recip = $orig_recip[0];
}
$msg_id = $this->_headers->getValue('Message-ID');
/* Create the Disposition field now (RFC 3798 [3.2.6]). */
$dispo = 'Disposition: ' . ($action ? 'manual-action' : 'automatic-action') . '/' . ($sending ? 'MDN-sent-manually' : 'MDN-sent-automatically') . '; ' . $type;
if (!empty($mod)) {
$dispo .= '/' . implode(', ', $mod);
}
/* Set up the mail headers. */
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addMessageIdHeader();
$msg_headers->addUserAgentHeader($ua);
$msg_headers->addHeader('Date', date('r'));
if ($opts['from_addr']) {
$msg_headers->addHeader('From', $opts['from_addr']);
}
$msg_headers->addHeader('To', $this->getMdnReturnAddr());
$msg_headers->addHeader('Subject', Horde_Mime_Translation::t("Disposition Notification"));
/* MDNs are a subtype of 'multipart/report'. */
$msg = new Horde_Mime_Part();
$msg->setType('multipart/report');
$msg->setContentTypeParameter('report-type', 'disposition-notification');
/* The first part is a human readable message. */
$part_one = new Horde_Mime_Part();
$part_one->setType('text/plain');
$part_one->setCharset($opts['charset']);
if ($type == 'displayed') {
$contents = sprintf(Horde_Mime_Translation::t("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('Subject'));
$flowed = new Horde_Text_Flowed($contents, $opts['charset']);
$flowed->setDelSp(true);
$part_one->setContentTypeParameter('format', 'flowed');
$part_one->setContentTypeParameter('DelSp', 'Yes');
$part_one->setContents($flowed->toFlowed());
}
// TODO: Messages for other notification types.
$msg->addPart($part_one);
/* The second part is a machine-parseable description. */
$part_two = new Horde_Mime_Part();
$part_two->setType('message/disposition-notification');
$part_two_text = array('Reporting-UA: ' . $name . '; ' . $ua . "\n");
if (!empty($orig_recip)) {
$part_two_text[] = 'Original-Recipient: rfc822;' . $orig_recip . "\n";
}
if ($opts['from_addr']) {
$part_two_text[] = 'Final-Recipient: rfc822;' . $opts['from_addr'] . "\n";
}
if (!empty($msg_id)) {
$part_two_text[] = 'Original-Message-ID: rfc822;' . $msg_id . "\n";
}
$part_two_text[] = $dispo . "\n";
if (in_array('error', $mod) && isset($err['error'])) {
$part_two_text[] = 'Error: ' . $err['error'] . "\n";
}
$part_two->setContents($part_two_text);
$msg->addPart($part_two);
/* The third part is the text of the original message. RFC 3798 [3]
* allows us to return only a portion of the entire message - this
* is left up to the user. */
$part_three = new Horde_Mime_Part();
$part_three->setType('message/rfc822');
$part_three_text = array($this->_headers->toString());
if (!empty($this->_msgtext)) {
$part_three_text[] = $part_three->getEOL() . $this->_msgtext;
//.........这里部分代码省略.........
示例7: _reportDigest
/**
* Builds and sends a digest message.
*
* @param array $messages List of message contents (string|resource).
* @param integer $action Either Horde_Spam::SPAM or Horde_Spam::INNOCENT.
*
* @return integer The number of reported messages.
*/
protected function _reportDigest(array $messages, $action)
{
if (empty($messages)) {
return 0;
}
/* Build the MIME structure. */
$mime = new Horde_Mime_Part();
$mime->setType('multipart/digest');
foreach ($messages as $val) {
$rfc822 = new Horde_Mime_Part();
$rfc822->setType('message/rfc822');
$rfc822->setContents($val);
$mime[] = $rfc822;
}
$spam_headers = new Horde_Mime_Headers();
$spam_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
$spam_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
$spam_headers->addHeader('To', $this->_email);
$spam_headers->addHeader('From', $this->_from_addr);
$spam_headers->addHeader('Subject', sprintf(Horde_Spam_Translation::t("%s report from %s"), $action === Horde_Spam::SPAM ? 'spam' : 'innocent', $this->_user));
/* Send the message. */
try {
$mime->send($this->_email, $spam_headers, $this->_mail);
return count($messages);
} catch (Horde_Mail_Exception $e) {
$this->_logger->warn($e);
return 0;
}
}