0
sendgrid 메일러를 사용하고 있으며 메일 기능에 CSV 파일을 첨부하지 못했습니다. 다음은 메일 작성을위한 코드입니다. ...sendgrid를 사용하여 이메일에 파일 첨부
$ resumeName = $ _FILES [ 'resume'] [ 'name'];
$ resumePath = $ _FILES [ 'resume'] [ 'tmp_name'];
이public static function sendMailwithAttachment($mail_type, $mail_variable = array(), $subject, $from, $to, $resumeName, $resumePath) {
$CI = & get_instance();
if ($mail_type !== NULL) {
$CI->db->select('tpl');
$CI->db->from('tblMailTypes');
$CI->db->where('id', $mail_type);
$query = $CI->db->get();
$mailIdres = $query->result_array();
if (!empty($mailIdres)) {
$message = $mailIdres[0]['tpl'];
if (!empty($mail_variable)) {
foreach ($mail_variable as $key => $val) {
$message = str_ireplace($key, $val, $message); // select message format from table
}
}
}
}
$from = new SendGrid\Email(null, $from);
$to = new SendGrid\Email(null, $to);
$content = new SendGrid\Content("text/html", $message);
exit();
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = 'ABCD..................HHHHFFFRRDSE'; // Sendgrid API key
$sg = new \SendGrid($apiKey);
addAttachment($resumePath, $resumeName);
$response = $sg->client->mail()->send()->post($mail);
}
사람이 완벽하게 작동