少し変更した
このコミットが含まれているのは:
コミット
92c2bcf22a
|
@ -45,6 +45,8 @@ MAIL_HOST=smtp.mailtrap.io
|
||||||
MAIL_PORT=2525
|
MAIL_PORT=2525
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_NOREPLY_USER=null
|
||||||
|
MAIL_NOREPLY_PASS=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
MAIL_OWNER_ADDRESS=null
|
MAIL_OWNER_ADDRESS=null
|
||||||
MAIL_OWNER_NAME="${APP_NAME}"
|
MAIL_OWNER_NAME="${APP_NAME}"
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Contact {
|
||||||
// 文章
|
// 文章
|
||||||
if (!isset($this->field['bunsyo']) || is_null($this->field['bunsyo']) || $this->field['bunsyo'] == '') $err[] = '文章をご入力下さい。';
|
if (!isset($this->field['bunsyo']) || is_null($this->field['bunsyo']) || $this->field['bunsyo'] == '') $err[] = '文章をご入力下さい。';
|
||||||
if (str_contains($this->field['bunsyo'], 'http://') || str_contains($this->field['bunsyo'], 'https://')) $err[] = '文章でURLを入らないで下さい。';
|
if (str_contains($this->field['bunsyo'], 'http://') || str_contains($this->field['bunsyo'], 'https://')) $err[] = '文章でURLを入らないで下さい。';
|
||||||
$this->field['bunsyo'] = $gpg->encrypt(trim($this->field['bunsyo']));
|
$this->field['bunsyo'] = $gpg->encrypt(trim("メール: ".$this->field['adr']."\n\n".$this->field['bunsyo']));
|
||||||
|
|
||||||
// 連絡ルール
|
// 連絡ルール
|
||||||
if (!$this->field['ruleapply']) $err[] = 'ルールを同意して下さい。';
|
if (!$this->field['ruleapply']) $err[] = 'ルールを同意して下さい。';
|
||||||
|
@ -110,7 +110,7 @@ class Contact {
|
||||||
// メールを送る
|
// メールを送る
|
||||||
try {
|
try {
|
||||||
$mail = new MailerController();
|
$mail = new MailerController();
|
||||||
if (!$mail->compose($this->field)) {
|
if (!$mail->compose($this->field, true)) {
|
||||||
Storage::disk('public')->delete($this->field['filename']);
|
Storage::disk('public')->delete($this->field['filename']);
|
||||||
return view('pages.site.contact', ['field' => $this->field, 'err' => ['送信に失敗しました。数時間後もう一回送信してみて下さい。']]);
|
return view('pages.site.contact', ['field' => $this->field, 'err' => ['送信に失敗しました。数時間後もう一回送信してみて下さい。']]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,22 +13,27 @@ use PHPMailer\PHPMailer\Exception;
|
||||||
class MailerController extends Controller {
|
class MailerController extends Controller {
|
||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
|
|
||||||
public function compose ($val) {
|
public function compose ($val, $form=false) {
|
||||||
|
mb_language('japanese');
|
||||||
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
$mail = new PHPMailer(true);
|
$mail = new PHPMailer(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$mail->SMTPDebug = 1;
|
// $mail->SMTPDebug = 2;
|
||||||
$mail->isSMTP();
|
$mail->isSMTP();
|
||||||
$mail->Host = config('mail.mailers.smtp.host');
|
$mail->Host = config('mail.mailers.smtp.host');
|
||||||
$mail->Port = config('mail.mailers.smtp.port');
|
$mail->Port = config('mail.mailers.smtp.port');
|
||||||
$mail->SMTPSecure = config('mail.mailers.smtp.encryption');
|
$mail->SMTPSecure = config('mail.mailers.smtp.encryption');
|
||||||
$mail->SMTPAuth = true;
|
$mail->SMTPAuth = true;
|
||||||
$mail->From = config('mail.owner.address');
|
$mail->From = config('mail.'.($form ? 'owner' : 'from').'.address');
|
||||||
$mail->Username = config('mail.mailers.smtp.username');
|
$mail->FromName = mb_encode_mimeheader(config('mail.mailers.smtp.'.($form ? 'fromname' : 'noreplyfrom')), 'JIS');
|
||||||
$mail->Password = config('mail.mailers.smtp.password');
|
$mail->Username = config('mail.mailers.smtp.'.($form ? 'username' : 'noreplyuser'));
|
||||||
|
$mail->Password = config('mail.mailers.smtp.'.($form ? 'password' : 'noreplypass'));
|
||||||
|
|
||||||
$mail->AddAddress(config('mail.owner.address'));
|
$mail->AddAddress(config('mail.'.($form ? 'owner' : 'from').'.address'));
|
||||||
$mail->addReplyTo(config('mail.owner.address'), config('mail.owner.name'));
|
if ($form) $mail->addReplyTo(config('mail.owner.address'), config('mail.owner.name'));
|
||||||
|
else $mail->addReplyTo($val['adr']);
|
||||||
|
|
||||||
$mail->SMTPOptions = [
|
$mail->SMTPOptions = [
|
||||||
'ssl' => [
|
'ssl' => [
|
||||||
|
@ -45,13 +50,15 @@ class MailerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($val['gpg'])) {
|
if (isset($val['gpg'])) {
|
||||||
$mail->AddStringAttachment($val['gpg'], $val['gpgname']);
|
$mail->AddStringAttachment($val['gpg'], $val['filename']);
|
||||||
|
$mail->AddStringAttachment($val['bunsyo'], $val['adr'].'.gpg');
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail->isHTML(false);
|
$mail->isHTML(false);
|
||||||
|
|
||||||
$mail->Subject = '【'.$val['catname'].'】'.$val['kenmei'];
|
$mail->Subject = mb_encode_mimeheader('【'.$val['catname'].'】'.$val['kenmei'], 'JIS');
|
||||||
$mail->Body = "メール:".$val['adr']."\n\n".$val['bunsyo'];
|
if ($form) $mail->Body = mb_convert_encoding($val['bunsyo'], 'UTF-8');
|
||||||
|
else $mail->Body = mb_convert_encoding($val['bunsyo'], 'JIS');
|
||||||
|
|
||||||
if (!$mail->send()) {
|
if (!$mail->send()) {
|
||||||
Log::critical('Mailer error: ' . $mail->ErrorInfo);
|
Log::critical('Mailer error: ' . $mail->ErrorInfo);
|
||||||
|
|
|
@ -39,8 +39,12 @@ return [
|
||||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||||
'port' => env('MAIL_PORT', 587),
|
'port' => env('MAIL_PORT', 587),
|
||||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||||
|
'fromname' => env('MAIL_OWNER_NAME'),
|
||||||
'username' => env('MAIL_USERNAME'),
|
'username' => env('MAIL_USERNAME'),
|
||||||
'password' => env('MAIL_PASSWORD'),
|
'password' => env('MAIL_PASSWORD'),
|
||||||
|
'noreplyfrom' => env('MAIL_FROM_NAME'),
|
||||||
|
'noreplyuser' => env('MAIL_NOREPLY_USER'),
|
||||||
|
'noreplypass' => env('MAIL_NOREPLY_PASS'),
|
||||||
'sendmail' => '/usr/sbin/sendmail -bs',
|
'sendmail' => '/usr/sbin/sendmail -bs',
|
||||||
'timeout' => null,
|
'timeout' => null,
|
||||||
'auth_mode' => null,
|
'auth_mode' => null,
|
||||||
|
|
新しいイシューから参照