1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +01:00

Phabricator mail

Test Plan: EMPTY

Reviewers: aran, epriestley

Reviewed By: epriestley

CC: aran, mareksapota, epriestley, jungejason, nh, drnikki

Differential Revision: 1002
This commit is contained in:
Marek Sapota 2011-10-14 12:07:29 -07:00
parent 0bf2753b88
commit fee7184350
5 changed files with 44 additions and 0 deletions

View file

@ -22,6 +22,7 @@ abstract class PhabricatorMailImplementationAdapter {
abstract public function addReplyTo($email, $name = ''); abstract public function addReplyTo($email, $name = '');
abstract public function addTos(array $emails); abstract public function addTos(array $emails);
abstract public function addCCs(array $emails); abstract public function addCCs(array $emails);
abstract public function addAttachment($data, $filename, $mimetype);
abstract public function addHeader($header_name, $header_value); abstract public function addHeader($header_name, $header_value);
abstract public function setBody($body); abstract public function setBody($body);
abstract public function setSubject($subject); abstract public function setSubject($subject);

View file

@ -55,6 +55,16 @@ class PhabricatorMailImplementationPHPMailerLiteAdapter
return $this; return $this;
} }
public function addAttachment($data, $filename, $mimetype) {
$this->mailer->AddStringAttachment(
$data,
$filename,
'base64',
$mimetype
);
return $this;
}
public function addHeader($header_name, $header_value) { public function addHeader($header_name, $header_value) {
if (strtolower($header_name) == 'message-id') { if (strtolower($header_name) == 'message-id') {
$this->mailer->MessageID = $header_value; $this->mailer->MessageID = $header_value;

View file

@ -55,6 +55,12 @@ class PhabricatorMailImplementationSendGridAdapter
return $this; return $this;
} }
public function addAttachment($data, $filename, $mimetype) {
throw new Exception(
'SendGrid adapter does not currently support attachments.'
);
}
public function addHeader($header_name, $header_value) { public function addHeader($header_name, $header_value) {
$this->params['headers'][] = array($header_name, $header_value); $this->params['headers'][] = array($header_name, $header_value);
return $this; return $this;

View file

@ -61,6 +61,15 @@ class PhabricatorMailImplementationTestAdapter
return $this; return $this;
} }
public function addAttachment($data, $filename, $mimetype) {
$this->guts['attachments'][] = array(
'data' => $data,
'filename' => $filename,
'mimetype' => $mimetype
);
return $this;
}
public function addHeader($header_name, $header_value) { public function addHeader($header_name, $header_value) {
$this->guts['headers'][] = array($header_name, $header_value); $this->guts['headers'][] = array($header_name, $header_value);
return $this; return $this;

View file

@ -104,6 +104,15 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this; return $this;
} }
public function addAttachment($data, $filename, $mimetype) {
$this->parameters['attachments'][] = array(
'data' => $data,
'filename' => $filename,
'mimetype' => $mimetype
);
return $this;
}
public function setFrom($from) { public function setFrom($from) {
$this->setParam('from', $from); $this->setParam('from', $from);
return $this; return $this;
@ -284,6 +293,15 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
$mailer->addHeader($header_key, $header_value); $mailer->addHeader($header_key, $header_value);
} }
break; break;
case 'attachments':
foreach ($value as $attachment) {
$mailer->addAttachment(
$attachment['data'],
$attachment['filename'],
$attachment['mimetype']
);
}
break;
case 'body': case 'body':
$mailer->setBody($value); $mailer->setBody($value);
break; break;