mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-05 17:08:56 +02:00
PHPStorm refactoring.
This commit is contained in:
+53
-55
@@ -18,74 +18,72 @@ namespace Mage;
|
||||
*/
|
||||
class Mailer
|
||||
{
|
||||
const EOL = "\r\n";
|
||||
const SUBJECT = '[Magallanes] Deployment of {project} to {environment}: {result}';
|
||||
const EOL = "\r\n";
|
||||
const SUBJECT = '[Magallanes] Deployment of {project} to {environment}: {result}';
|
||||
|
||||
protected $address;
|
||||
protected $project;
|
||||
protected $environment;
|
||||
protected $logFile;
|
||||
protected $address;
|
||||
protected $project;
|
||||
protected $environment;
|
||||
protected $logFile;
|
||||
|
||||
public function setAddress($address)
|
||||
{
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function setProject($project)
|
||||
{
|
||||
$this->project = $project;
|
||||
return $this;
|
||||
}
|
||||
public function setProject($project)
|
||||
{
|
||||
$this->project = $project;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
return $this;
|
||||
}
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLogFile($logFile)
|
||||
{
|
||||
$this->logFile = $logFile;
|
||||
return $this;
|
||||
}
|
||||
public function setLogFile($logFile)
|
||||
{
|
||||
$this->logFile = $logFile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send($result)
|
||||
{
|
||||
$boundary = md5(date('r', time()));
|
||||
$boundary = md5(date('r', time()));
|
||||
|
||||
$headers = 'From: ' . $this->address
|
||||
. self::EOL
|
||||
. 'Reply-To: ' . $this->address
|
||||
. self::EOL
|
||||
. 'MIME-Version: 1.0'
|
||||
. self::EOL
|
||||
. 'Content-Type: multipart/mixed; boundary=Mage-mixed-' . $boundary;
|
||||
$headers = 'From: ' . $this->address
|
||||
. self::EOL
|
||||
. 'Reply-To: ' . $this->address
|
||||
. self::EOL
|
||||
. 'MIME-Version: 1.0'
|
||||
. self::EOL
|
||||
. 'Content-Type: multipart/mixed; boundary=Mage-mixed-' . $boundary;
|
||||
|
||||
$subject = str_replace(
|
||||
array('{project}', '{environment}', '{result}'),
|
||||
array($this->project, $this->environment, $result ? 'SUCCESS' : 'FAILURE'),
|
||||
self::SUBJECT
|
||||
)
|
||||
;
|
||||
$attachment = chunk_split(base64_encode(file_get_contents($this->logFile)));
|
||||
$subject = str_replace(
|
||||
array('{project}', '{environment}', '{result}'),
|
||||
array($this->project, $this->environment, $result ? 'SUCCESS' : 'FAILURE'),
|
||||
self::SUBJECT
|
||||
);
|
||||
$attachment = chunk_split(base64_encode(file_get_contents($this->logFile)));
|
||||
|
||||
$message = 'This is a multi-part message in MIME format.' . self::EOL
|
||||
. '--Mage-mixed-' . $boundary . self::EOL
|
||||
. 'Content-Type: text/plain; charset=iso-8859-1' . self::EOL
|
||||
. 'Content-Transfer-Encoding: quoted-printable' . self::EOL
|
||||
. self::EOL
|
||||
. strip_tags(Console::getOutput()) . self::EOL
|
||||
. self::EOL
|
||||
. '--Mage-mixed-' . $boundary . self::EOL
|
||||
. 'Content-Type: text/plain; name="log.txt"' . self::EOL
|
||||
. 'Content-Transfer-Encoding: base64' . self::EOL
|
||||
. 'Content-Disposition: attachment' . self::EOL
|
||||
. self::EOL
|
||||
. $attachment . self::EOL
|
||||
. '--Mage-mixed-' . $boundary . '--' . self::EOL
|
||||
;
|
||||
$message = 'This is a multi-part message in MIME format.' . self::EOL
|
||||
. '--Mage-mixed-' . $boundary . self::EOL
|
||||
. 'Content-Type: text/plain; charset=iso-8859-1' . self::EOL
|
||||
. 'Content-Transfer-Encoding: quoted-printable' . self::EOL
|
||||
. self::EOL
|
||||
. strip_tags(Console::getOutput()) . self::EOL
|
||||
. self::EOL
|
||||
. '--Mage-mixed-' . $boundary . self::EOL
|
||||
. 'Content-Type: text/plain; name="log.txt"' . self::EOL
|
||||
. 'Content-Transfer-Encoding: base64' . self::EOL
|
||||
. 'Content-Disposition: attachment' . self::EOL
|
||||
. self::EOL
|
||||
. $attachment . self::EOL
|
||||
. '--Mage-mixed-' . $boundary . '--' . self::EOL;
|
||||
|
||||
@mail($this->address, $subject, $message, $headers);
|
||||
@mail($this->address, $subject, $message, $headers);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user