1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +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 addTos(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 setBody($body);
abstract public function setSubject($subject);

View file

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

View file

@ -55,6 +55,12 @@ class PhabricatorMailImplementationSendGridAdapter
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) {
$this->params['headers'][] = array($header_name, $header_value);
return $this;

View file

@ -61,6 +61,15 @@ class PhabricatorMailImplementationTestAdapter
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) {
$this->guts['headers'][] = array($header_name, $header_value);
return $this;

View file

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