diff --git a/data/Smarty/templates/default/mail_templates/customer_mail.tpl b/data/Smarty/templates/default/mail_templates/customer_mail.tpl index 3eefb1f8dc..b955be97cf 100644 --- a/data/Smarty/templates/default/mail_templates/customer_mail.tpl +++ b/data/Smarty/templates/default/mail_templates/customer_mail.tpl @@ -33,7 +33,7 @@  ご連絡いただければ幸いです。 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - 様 + でございます。 @@ -44,7 +44,7 @@ 本会員登録を完了するには下記URLにアクセスしてください。 ※入力されたお客様の情報はSSL暗号化通信により保護されます。 -regist/?mode=regist&id= +regist/?mode=regist&id= 上記URLにて本会員登録が完了いたしましたら改めてご登録内容ご確認 メールをお送り致します。 diff --git a/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl b/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl index 4db002abbd..481bcebb5a 100644 --- a/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl +++ b/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl @@ -32,7 +32,7 @@  ご連絡いただければ幸いです。 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - 様 +でございます。 diff --git a/data/class/helper/SC_Helper_Mail.php b/data/class/helper/SC_Helper_Mail.php index 3fc82696e2..d76c1cb52e 100644 --- a/data/class/helper/SC_Helper_Mail.php +++ b/data/class/helper/SC_Helper_Mail.php @@ -349,7 +349,7 @@ public function sfCheckCustomerMailMaga($email) /** * 登録メールを送信する。 * - * @param string $secret_key 会員固有キー + * @param string $secret_key 会員固有キー。$customer_id に有効な数値が指定されると、無視される。 * @param integer $customer_id 会員ID * @param boolean $is_mobile false(default):PCアドレスにメールを送る true:携帯アドレスにメールを送る * @param $resend_flg true 仮登録メール再送 @@ -373,20 +373,22 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa $objMailText = new SC_SiteView_Ex(); $objMailText->setPage($this->getPage()); $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $arrCustomerData['name01']); - $objMailText->assign('name02', $arrCustomerData['name02']); + $objMailText->assign('arrCustomer', $arrCustomerData); + + // 旧テンプレート互換用 https://github.com/EC-CUBE/ec-cube2/issues/982 + $objMailText->assignarray($arrCustomerData); $objMailText->assign('uniqid', $arrCustomerData['secret_key']); - $objMailText->assignobj($arrCustomerData); $objHelperMail = new SC_Helper_Mail_Ex(); - // 仮会員が有効の場合 - if (CUSTOMER_CONFIRM_MAIL == true and $arrCustomerData['status'] == 1 or $arrCustomerData['status'] == 1 and $resend_flg == true) { + // 仮会員が有効の場合 (FIXME: コメント不正確) + if ($arrCustomerData['status'] == 1 + && (CUSTOMER_CONFIRM_MAIL == true || $resend_flg == true) + ) { $subject = $objHelperMail->sfMakeSubject('会員登録のご確認', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); } else { $subject = $objHelperMail->sfMakeSubject('会員登録のご完了', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - } $objMail = new SC_SendMail_Ex(); diff --git a/data/class/pages/admin/customer/LC_Page_Admin_Customer.php b/data/class/pages/admin/customer/LC_Page_Admin_Customer.php index 3d968af10f..8ab63e5a2c 100644 --- a/data/class/pages/admin/customer/LC_Page_Admin_Customer.php +++ b/data/class/pages/admin/customer/LC_Page_Admin_Customer.php @@ -190,12 +190,13 @@ public function lfDoResendMail($customer_id) //対象となるデータが見つからない、または削除済み return false; } - //仮登録メール再送 - $resend_flg = true; - // 登録メール再送 + + // 仮登録メール送信 $objHelperMail = new SC_Helper_Mail_Ex(); $objHelperMail->setPage($this); + $resend_flg = true; $objHelperMail->sfSendRegistMail($arrData['secret_key'], $customer_id, null, $resend_flg); + return true; } diff --git a/data/class/pages/entry/LC_Page_Entry.php b/data/class/pages/entry/LC_Page_Entry.php index 03920f391b..cafb2dcc1a 100644 --- a/data/class/pages/entry/LC_Page_Entry.php +++ b/data/class/pages/entry/LC_Page_Entry.php @@ -222,44 +222,11 @@ public function lfMakeSqlVal(&$objFormParam) */ public function lfSendMail($uniqid, $arrForm) { - $CONF = SC_Helper_DB_Ex::sfGetBasisData(); + $objHelperMail = new SC_Helper_Mail_Ex(); - $objMailText = new SC_SiteView_Ex(); - $objMailText->setPage($this); - $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $arrForm['name01']); - $objMailText->assign('name02', $arrForm['name02']); - $objMailText->assign('uniqid', $uniqid); - - $objHelperMail = new SC_Helper_Mail_Ex(); $objHelperMail->setPage($this); - - // 仮会員が有効の場合 - if (CUSTOMER_CONFIRM_MAIL == true) { - $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); - } else { - $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - } - - $objMail = new SC_SendMail_Ex(); - $objMail->setItem( - '', // 宛先 - $subject, // サブジェクト - $toCustomerMail, // 本文 - $CONF['email03'], // 配送元アドレス - $CONF['shop_name'], // 配送元 名前 - $CONF['email03'], // reply_to - $CONF['email04'], // return_path - $CONF['email04'], // Errors_to - $CONF['email01'] // Bcc - ); - // 宛先の設定 - $objMail->setTo($arrForm['email'], - $arrForm['name01'] . $arrForm['name02'] .' 様'); - - $objMail->sendMail(); + $resend_flg = true; + $objHelperMail->sfSendRegistMail($uniqid, '', false, $resend_flg); } /** diff --git a/data/class/pages/regist/LC_Page_Regist.php b/data/class/pages/regist/LC_Page_Regist.php index cc96a408df..930e5b00dd 100644 --- a/data/class/pages/regist/LC_Page_Regist.php +++ b/data/class/pages/regist/LC_Page_Regist.php @@ -135,40 +135,9 @@ public function lfCheckError($array) */ public function lfSendRegistMail($registSecretKey) { - $objQuery = SC_Query_Ex::getSingletonInstance(); - $objCustomer = new SC_Customer_Ex(); - $objHelperMail = new SC_Helper_Mail_Ex(); + $objHelperMail = new SC_Helper_Mail_Ex(); + $objHelperMail->setPage($this); - $CONF = SC_Helper_DB_Ex::sfGetBasisData(); - - //-- 会員データを取得 - $arrCustomer = $objQuery->select('*', 'dtb_customer', 'secret_key = ?', array($registSecretKey)); - $data = $arrCustomer[0]; - $objCustomer->setLogin($data['email']); - - //-- メール送信 - $objMailText = new SC_SiteView_Ex(); - $objMailText->setPage($this); - $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $data['name01']); - $objMailText->assign('name02', $data['name02']); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - $subject = $objHelperMail->sfMakesubject('会員登録が完了しました。'); - $objMail = new SC_SendMail_Ex(); - - $objMail->setItem( - '', // 宛先 - $subject, // サブジェクト - $toCustomerMail, // 本文 - $CONF['email03'], // 配送元アドレス - $CONF['shop_name'], // 配送元 名前 - $CONF['email03'], // reply_to - $CONF['email04'], // return_path - $CONF['email04'] // Errors_to - ); - // 宛先の設定 - $name = $data['name01'] . $data['name02'] .' 様'; - $objMail->setTo($data['email'], $name); - $objMail->sendMail(); + $objHelperMail->sfSendRegistMail($registSecretKey); } } diff --git a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php new file mode 100644 index 0000000000..b366d124e5 --- /dev/null +++ b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php @@ -0,0 +1,50 @@ +checkMailCatcherStatus(); + $this->objHelperMail = new SC_Helper_Mail_Ex(); + + $this->faker = Faker\Factory::create('ja_JP'); + } + + protected function tearDown() + { + parent::tearDown(); + } + + protected function setUpCustomer($properties = []) + { + $this->email = $this->faker->safeEmail; + $this->customer_id = $this->objGenerator->createCustomer($this->email, $properties); + $this->arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_id]); + $this->objCustomer = new SC_Customer_Ex(); + } +} diff --git a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php new file mode 100644 index 0000000000..505d561181 --- /dev/null +++ b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php @@ -0,0 +1,46 @@ +setUpCustomer(); + + $this->resetEmails(); + $this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key']); + + $message = $this->getLastMailCatcherMessage(); + $this->assertContains($this->arrCustomer['name01'] . $this->arrCustomer['name02'] . ' 様', $message['source']); + } + + public function test会員登録依頼メールの宛名と登録リンクのidが正しい() + { + # 仮会員を作成 + $this->setUpCustomer(['status' => 1]); + + $this->resetEmails(); + $this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key'], '', false, true); + + $message = $this->getLastMailCatcherMessage(); + $this->assertContains($this->arrCustomer['name01'] . ' ' . $this->arrCustomer['name02'] . ' 様', $message['source']); + $this->assertContains('&id=' . $this->arrCustomer['secret_key'], $message['source']); + } +}