-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Example:
$mailer = Email::forge();
$body = View::forge('email/template', $data);
$mailer->html_body($body);
foreach ($mailing_list as $user) {
$body->set('user', $user);
$mailer->to($user['email'])->send();
}
Code like this throw error or work slow because multi sending not supported.
Rework:
body/alt_bodytyped inEmail_Driver::send(), not in setters- Add method
Email_Driver::before_send()called inEmail_Driver::send()init properties only once - Parse attachments from body is bad solution.
Also:
email/classes/email/driver.php
Line 233 in 5d09652
$cid = 'cid:'.md5(pathinfo($image_url, PATHINFO_BASENAME));
'second/img.jpg' rewrite 'firtst/img.jpg'
Email\View_Body would solve it:
namespace Email;
use Fuel\Core\View;
class View_Body extends View
{
protected $email;
protected $attachments = [];
public function __construct(Email_Driver $email, $file = null, $data = [], $filter = null)
{
$this->email = $email;
$this->bind('email', $this->email);
parent::__construct($file, $data, $filter);
}
public function set_filename($file, $reverse = false)
{
// TODO: add in config `'base_dir' => 'emails'` - directory with mail templates
if ($dir = $this->email->get_config('email.defaults.base_dir'))
{
$file = $dir.DIRECTORY_SEPARATOR.$file;
}
return parent::set_filename($file, $reverse);
}
public function render($file = null)
{
// TODO: update method `clear_attachments` for optional clear
$this->email->clear_attachments('inline');
$this->attachments = [];
return parent::render($file);
}
/**
* Template helper.
* @example `<img src="<?=$this->attach_inline($url)?>">`
* @param string $path Path/URL to file
* @return string CID
*/
protected function attach_inline($path)
{
$id = 'cid:'.md5($path);
if (!in_array($id, $this->attachments))
{
$this->email->attach($path, true, $id);
$this->attachments[] = $id;
}
return $id;
}
}
Metadata
Metadata
Assignees
Labels
No labels