0
codeigniterに送信グリッド付きの添付メールを送信しています。メールは正常に送信されましたが、ダウンロード後に添付ファイルが表示されませんでした。私のコード: -codeigniterに送信グリッド付きの添付メールを送信しています
public function test() {
$attach = base_url()."/uploads/a.png";
$this->SendMail('[email protected]', '[email protected]', 'sss sub', 'ss msg',$attach, 'dss.png');
}
送信グリッドAPI
function SendMail($from, $email, $subject, $message, $attach = '', $filename = '')
{
$url = 'https://api.sendgrid.com/';
$user = 'XXXXXX';
$pass = 'XXXXXX';
if ($attach <> '' && $filename <> '') {
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $email,
'fromname' => $from,
'from' => $from,
'subject' => $subject,
'html' => $message,
'files[' . $filename . ']' => new \CurlFile($attach),
'files[' . $filename . ']' => '@' . $attach,
);
} else {
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $email,
'fromname' => $from,
'from' => $from,
'subject' => $subject,
'html' => $message);
}
$request = $url . 'api/mail.send.json';
$session = curl_init($request);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
// Tell PHP not to use SSLv3 (instead opting for TLS)
//curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
return true;
}