Jump to content

how to attach a file with email in mailalerts module


Recommended Posts

hello there,

 

i want to attach a file (example.jpg) in mailalerts  module. i tried with following code. it does not work  :(. please help me out with this. 

 

thanks  in advance.

#mailalerts.php line 386
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
            file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html')){
            $template->attach(new Swift_Message_Attachment(file_get_contents("path/images/logo.png"), "logo.png", "image/png"));
                Mail::Send(
                    $id_lang,
                    $template,
                    sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
                    $template_vars,
                    explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
                    null,
                    $configuration['PS_SHOP_EMAIL'],
                    $configuration['PS_SHOP_NAME'],
                    null,
                    null,
                    dirname(__FILE__).'/mails/'
                );
        }
Edited by mani313 (see edit history)
Link to comment
Share on other sites

hello sir,

 

thanks for helping me out. our client little altered problem requirement again. now we only need to send copy of order confirmation email to printing company with one file attachment (ie sketch image). so as your suggestion i decide to use mail alerts module. though the problem minimized still its seems difficult. please mention where it gone wrong sir 

 

i tried your code. it outputs error : "The following e-mail template is missing: logo.pngen/new_order.txt " .  please mention where it gone wrong sir .

if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
			file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
			Mail::Send(
				$id_lang,
				$template,
				sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
				$template_vars,
				explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
				null,
				$configuration['PS_SHOP_EMAIL'],
				$configuration['PS_SHOP_NAME'],
				null,
				$file_attachement['content'] = file_get_contents("path/images/logo.png"),
				$file_attachement['name'] = "logo.png",
				$file_attachement['mime'] = "image/png",
				dirname(__FILE__).'/mails/'
			);

thanks  in advance 

Link to comment
Share on other sites

×
×
  • Create New...