php - Unable to send emails with attachment using elastic email API in codeigniter -


i have used tcpdf generate pdf, working fine.i'm trying send email pdf generated attachment email. emails being sent without attachment. please in correcting codes below ensure attachment sent in email.

payment.php

$attachment =  $pdf->output('example_001.pdf', 'd'); $attachment = base64_encode($attachment);  $attachmentlink = 'http://localhost/cfac/resources/invoices/example_001.pdf';  $inputdata['firstname']="abc"; $inputdata['ename']="event name"; $inputdata['tno']="tno:232423"; $inputdata['amount']="10000rs"; $inputdata['edetails']="edetails"; $inputdata['startdate']="start date"; $inputdata['enddate']="end date"; $template='xyz';  $emailid="xxx@gmail.com"; // email helper send email $this->load->helper ('email');          $filename = "example_001.pdf";         $file_name_with_full_path = base_url()."resources/inv/example_001.pdf";         $filetype = "application/pdf";          $attachmentfiles = array('http://localhost/cfac/resources/inv/example_001.pdf');           send_email($emailid,$inputdata,$template, $attachmentfiles ); 

emailhelper.php

emailconfig deatils have been set values in config file.

<?php if ( ! defined('basepath')) exit('no direct script access allowed');   if ( ! function_exists('send_email')) {  function send_email($emailid,$inputdata,$template,$attachmentfiles ) {      $ci =& get_instance();     $ci->load->config('emailcofnig');     //$ci->email->attach( 'http://localhost/cfac/resources/inv/example_001.pdf');      $emailconfig=$ci->config->item('elasticemail');      $url=$emailconfig['url'];      $filename = "example_001.pdf";     $file_name_with_full_path = "http://localhost/cfac/resources/invoices/example_001.pdf";     $filetype = "application/pdf";       $email = array(         'from' => $emailconfig['fromemailid'],         'fromname' => $emailconfig['from'],         'apikey' => $emailconfig['apikey'],         'subject' => $emailconfig['defaultsubject'],         'to' => $emailid,         'istransactional' => true,         'template' => $templatename,         'file_1' => new curlfile($file_name_with_full_path, $filetype, $filename)         );          foreach($inputdata $key => $value)         {             $email['merge_'.$key] = $value;         }        // use key 'http' if send request https://...     $options = array(         'http' => array(             'header'  => "content-type: application/x-www-form-urlencoded\r\n",             'method'  => 'post',             'content' => http_build_query($email)         )     );      $context  = stream_context_create($options);     $result = file_get_contents($url, false, $context);     if ($result === false) { /* handle error */ return 0;}      } }  ?> 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -