for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the PHALCON-EXT package.
*
* (c) Jitendra Adhikari <[email protected]>
* <https://github.com/adhocore>
* Licensed under MIT license.
*/
namespace PhalconExt\Mail;
class Mail extends \Swift_Message
{
/** @var Mailer */
protected $mailer;
public function __construct(Mailer $mailer)
$this->mailer = $mailer;
parent::__construct();
}
/**
* Attach files.
* @param array $filePaths
* @return $this
public function attachFiles(array $filePaths): self
foreach ($filePaths as $alias => $filePath) {
$this->attachFile($filePath, \is_int($alias) ? null : $alias);
return $this;
* Attach file.
* @param string $filePath
* @param string|null $alias
* @return self
public function attachFile(string $filePath, string $alias = null): self
return $this->attach(
\Swift_Attachment::fromPath($filePath)->setFilename($alias ?? \basename($filePath))
);
* Attach raw data.
* @param string $data
* @param string $alias
* @param string $type
public function attachRaw(string $data, string $alias, string $type): self
new \Swift_Attachment($data, $alias, $type)
* Mail the mail with swift mailer.
* @return int The count of mailed recipients.
public function mail()
return $this->mailer->mail($this);