Last active
December 28, 2015 05:38
-
-
Save sakadonohito/7450823 to your computer and use it in GitHub Desktop.
FuelPHPのEmailパッケージを使ってファイルを添付する時の文字化け対策
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function sendmail($mail_info){ | |
$email = \Email::forge(); | |
$mail->from($mail_info['from']); | |
$mail->to($mail_info['to']); | |
$mail->cc($mail_info['cc']); | |
$mail->subject(mb_convert_kana($mail_info['subject'],"KV"));//件名に半角カナが含まれた場合を考慮して全角カナに変換 | |
//最初の引数はファイルを見つけるためにも使うのでそのまま、通常は第1引数のみ。文字化け対策に別名用引数の第5引数にエンコードした添付ファイル名を渡す | |
if(array_key_exists("attach",$mail_info)) $mail->attach($file_info['attach'],false,null,null,mb_convert_encoding($file_info['attach'],"ISO-2022-JP","CP932")); | |
$mail->body(mb_convert_encoding($mail_info['body'],"ISO-2022-JP")); | |
$mail->send(); | |
//本当は例外処理とかするのん | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment