public function enhanceMail(Codendi_Mail $mail) { foreach ($this->getAdditionalHeaders() as $name => $value) { $mail->addAdditionalHeader($name, $value); } foreach ($this->getAdditionalPropertiesForLookAndFeel() as $property => $value) { $mail->getLookAndFeelTemplate()->set($property, $value); } if ($this->getMessageId()) { $mail->getMail()->setMessageId($this->getMessageId()); } }
public function enhanceMail(Codendi_Mail $mail) { $headers = $this->getAdditionalHeaders(); $from_mail = null; if (array_key_exists('from', $headers)) { $from_mail = $headers['from']; unset($headers['from']); } if ($from_mail === null && array_key_exists('reply-to', $headers)) { $from_mail = $headers['reply-to']; } if ($from_mail !== null) { $mail->clearFrom(); $mail->setFrom($from_mail); } foreach ($headers as $name => $value) { $mail->addAdditionalHeader($name, $value); } foreach ($this->getAdditionalPropertiesForLookAndFeel() as $property => $value) { $mail->getLookAndFeelTemplate()->set($property, $value); } if ($this->getMessageId()) { $mail->getMail()->setMessageId($this->getMessageId()); } }
public function itHasAppropriateTypeForAttachment() { $mail = new Codendi_Mail(); $mail->addInlineAttachment('data', 'text/plain', 'attachment'); $this->assertEqual($mail->getMail()->getType(), 'multipart/related'); }
/** * Send a notification * * @param array $recipients the list of recipients * @param array $headers the additional headers * @param string $subject the subject of the message * @param string $htmlBody the html content of the message * @param string $txtBody the text content of the message * @param string $message_id the id of the message * @param string $from the from email address * * @return void */ protected function sendNotification($recipients, $headers, $subject, $htmlBody, $txtBody, $message_id, $from) { $mail = new Codendi_Mail(); if ($message_id) { $mail->getMail()->setMessageId($message_id); } $hp = Codendi_HTMLPurifier::instance(); $breadcrumbs = array(); $tracker = $this->getTracker(); $project = $tracker->getProject(); $artifactId = $this->getArtifact()->getID(); $project_unix_name = $project->getUnixName(true); $tracker_name = $tracker->getItemName(); $breadcrumbs[] = '<a href="' . get_server_url() . '/projects/' . $project_unix_name . '" />' . $project->getPublicName() . '</a>'; $breadcrumbs[] = '<a href="' . get_server_url() . '/plugins/tracker/?tracker=' . (int) $tracker->getId() . '" />' . $hp->purify($this->getTracker()->getName()) . '</a>'; $breadcrumbs[] = '<a href="' . get_server_url() . '/plugins/tracker/?aid=' . (int) $artifactId . '" />' . $hp->purify($this->getTracker()->getName() . ' #' . $artifactId) . '</a>'; $mail->getLookAndFeelTemplate()->set('breadcrumbs', $breadcrumbs); $mail->getLookAndFeelTemplate()->set('unsubscribe_link', $this->getUnsubscribeLink()); $mail->getLookAndFeelTemplate()->set('title', $hp->purify($subject)); $mail->setFrom($from); $mail->addAdditionalHeader("X-Codendi-Project", $project->getUnixName()); $mail->addAdditionalHeader("X-Codendi-Tracker", $tracker_name); $mail->addAdditionalHeader("X-Codendi-Artifact-ID", $this->getId()); foreach ($headers as $header) { $mail->addAdditionalHeader($header['name'], $header['value']); } $mail->setTo(implode(', ', $recipients)); $mail->setSubject($subject); if ($htmlBody) { $htmlBody .= $this->getHTMLBodyFilter($project_unix_name, $tracker_name); $mail->setBodyHTML($htmlBody); } $txtBody .= $this->getTextBodyFilter($project_unix_name, $tracker_name); $mail->setBodyText($txtBody); $mail->send(); }