I am trying to send an email with attachment using Amazon SES.
Here is what I am doing:
<?php
$file_path = DOC_ROOT.'/report/';
$myfile = $file_path.$filename;
$file_size = filesize($myfile);
$handle = fopen($myfile, "r");
$content = fread($handle, $file_size);
$subject = 'Report';
$content = chunk_split(base64_encode($content));
$header = "";
$message =
'<html>
<head><title></title></head>
<body>
<p>Hello '.$vEmail.',</p></br>
<p>Please find attached file.</p>
<p>Regards,</p>
<p>'.MAINTITLE.'</p></br>
</body>
</html>';
$ses = new Simpleemailservice(AWS_ACCESSKEY, AWS_SECRET);
$from = FROM_EMAIL_SES;
$uid = md5(uniqid(time()));
$header = "From: ".$from." <".$from.">
";
$header .= "To: ".$vEmail."
";
$header .= "Subject: ".$subject."
";
$header .= "MIME-Version: 1.0
";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"
";
$header .= "This is a multi-part message in MIME format.
";
$header .= "--".$uid."
";
$header .= "Content-type:text/html; charset=iso-8859-1
";
$header .= "Content-Transfer-Encoding: 7bit
";
$header .= $message."
";
$header .= "--".$uid."
";
$header .= "Content-Type: text/csv; name=\"".$myfile."\"
";
$header .= "Content-Transfer-Encoding: base64
";
$header .= "Content-Disposition: attachment; filename=\"".$myfile."\"
";
$header .= $content."
";
$header .= "--".$uid."--";
$msg['RawMessage']['Data'] = base64_encode($header);
$msg['RawMessage']['Source']= $from;
$msg['RawMessage']['Destinations'] = $vEmail;
fclose($handle);
$result = $ses->sendRawEmail($msg);
$msg_id = $result->get('MessageId');
?>
the error I am getting:
Fatal error: Call to a member function
setParameter()
on a non-object in/libraries/Simpleemailservice.php
on line 267
I found this Answer but it didn't help.