Re: 自動返信メールの実現

2017年9月19日 at 11:34

礼羽さん

レガシーフォームの編集ダイアログ上で、オプションタブを開くと「送信されたフォームをメールアドレスに送る」のチェックがあると思います。ここをチェックは入ってますでしょうか?
application/blocks/form/controller.phpの497行目あたりに下記のような条件判定があるので、「送信されたフォームをメールアドレスに送る」のチェックを入れていただければメールが飛ぶと思います。

if (intval($this->notifyMeOnSubmission) > 0 && !$foundSpam) {


もしくは、管理者等へ送る必要がない場合は、497行目付近を下記のような感じに書き換えていただければうまく行くと思いますが、どうでしょうか。

if (intval($this->notifyMeOnSubmission) > 0 && !$foundSpam) {
if (Config::get('concrete.email.form_block.address') && strstr(Config::get('concrete.email.form_block.address'), '@')) {
$formFormEmailAddress = Config::get('concrete.email.form_block.address');
} else {
$adminUserInfo = UserInfo::getByID(USER_SUPER_ID);
$formFormEmailAddress = $adminUserInfo->getUserEmail();
}
$mh = Core::make('helper/mail');
$mh->to($this->recipientEmail);
$mh->from($formFormEmailAddress);
$mh->replyto($replyToEmailAddress);
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('block_form_submission');
$mh->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh->body.'<br>';
@$mh->sendMail();
}
// ---------------------------------------------------------------
// 自動返信処理 Auto Reply
// ---------------------------------------------------------------
if ($sendConfirmationEmail && !$foundSpam) {
$adminUserInfo = UserInfo::getByID(USER_SUPER_ID);
$formFormEmailAddress = $adminUserInfo->getUserEmail();

$mh = null;
$mh = Core::make('helper/mail');
$mh->from($formFormEmailAddress); // 送信者メールアドレス(サイト管理者)
$mh->to($replyToEmailAddress); // 自動返信先(フォーム入力)
$mh->replyto($formFormEmailAddress); // 返信先メールアドレス(サイト管理者)
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('block_form_auto_reply'); // メールのテンプレート
$mh->setSubject(t('%s Form Submission', $this->surveyName)); // メールの件名
@$mh->sendMail();
}