ソースを参照

Layout email

Mise en place d'un layout propre pour les emails de La boîte à pain.
Adaptation et tests des emails d'inscription, de contact, de demande de nouveau mot de passe et d'envoi de récap des commandes.
Paramètrage de l'adresse email de contact admin (contact@laboiteapain.net).
prodstable
keun 7年前
コミット
98304dbedf
22個のファイルの変更209行の追加56行の削除
  1. +1
    -1
      backend/config/params.php
  2. +11
    -19
      backend/controllers/CronController.php
  3. +2
    -2
      common/config/params.php
  4. +9
    -0
      common/mail/contact-html.php
  5. +4
    -0
      common/mail/contact-text.php
  6. +1
    -2
      common/mail/createUserAdmin-html.php
  7. +1
    -2
      common/mail/createUserAdmin-text.php
  8. +16
    -0
      common/mail/cronRecapCommandes-html.php
  9. +20
    -0
      common/mail/cronRecapCommandes-text.php
  10. +51
    -1
      common/mail/layouts/html.php
  11. +4
    -0
      common/mail/layouts/text.php
  12. +1
    -2
      common/mail/passwordResetToken-html.php
  13. +1
    -2
      common/mail/passwordResetToken-text.php
  14. +27
    -0
      common/mail/signup-html.php
  15. +27
    -0
      common/mail/signup-text.php
  16. +1
    -1
      console/config/params.php
  17. +1
    -1
      frontend/config/params.php
  18. +24
    -3
      frontend/controllers/SiteController.php
  19. +7
    -3
      frontend/models/ContactForm.php
  20. +0
    -17
      frontend/models/SignupForm.php
  21. バイナリ
      frontend/web/img/laboiteapain-mail.png
  22. バイナリ
      frontend/web/img/laboiteapain-mail2.png

+ 1
- 1
backend/config/params.php ファイルの表示

@@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
'adminEmail' => 'contact@laboiteapain.net',
];

+ 11
- 19
backend/controllers/CronController.php ファイルの表示

@@ -79,9 +79,18 @@ class CronController extends BackendController
'status' => User::STATUS_BOULANGER
]) ;

$mail = Yii::$app->mailer->compose()
$mail = Yii::$app->mailer->compose(
[
'html' => 'cronRecapCommandes-html',
'text' => 'cronRecapCommandes-text',
],
[
'date' => $date,
'commandes' => $commandes
]
)
->setTo($user->email)
->setFrom(['contact@laboiteapain.net' => 'La boîte à pain']) ;
->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain']) ;

if(count($commandes))
{
@@ -96,30 +105,13 @@ class CronController extends BackendController
]);
$mail->attach(Yii::getAlias('@app/web/pdf/Commandes-'.$date.'-'.$e['id'].'.pdf')) ;

$message = 'Bonjour,

Voici en pièce jointe le récapitulatif des '.count($commandes).' commandes du '.date('d/m',strtotime($date)).'.

À bientôt,
La boîte à pain
' ;

}
else {
$sujet = '[La boîte à pain] Aucune commande' ;

$message = 'Bonjour,

Vous n\'avez aucune commande pour le '.date('d/m',strtotime($date)).'.

À bientôt,
La boîte à pain
' ;

}

$mail->setSubject($sujet)
->setTextBody($message)
->send();

}

+ 2
- 2
common/config/params.php ファイルの表示

@@ -1,6 +1,6 @@
<?php
return [
'adminEmail' => 'guillaume.bourgeois13@laposte.net',
'supportEmail' => 'support@example.com',
'adminEmail' => 'contact@laboiteapain.net',
'supportEmail' => 'contact@laboiteapain.net',
'user.passwordResetTokenExpire' => 3600,
];

+ 9
- 0
common/mail/contact-html.php ファイルの表示

@@ -0,0 +1,9 @@
<?php

use yii\helpers\Html;

?>

<p>Message de <strong><?= Html::encode($nom) ?></strong> :</p>

<?= nl2br(Html::encode($content)); ?>

+ 4
- 0
common/mail/contact-text.php ファイルの表示

@@ -0,0 +1,4 @@

Message de <?= $nom ?> :

<?= $content; ?>

+ 1
- 2
common/mail/createUserAdmin-html.php ファイルの表示

@@ -15,5 +15,4 @@ use yii\helpers\Html;
Identifiant : <strong><?= Html::encode($user->email); ?></strong><br />
Mot de passe : <strong><?= $password ?></strong></p>

<p>Cordialement,<br />
<em>La boîte à pain</em></p>
<p>À bientôt.</p>

+ 1
- 2
common/mail/createUserAdmin-text.php ファイルの表示

@@ -9,5 +9,4 @@ Voci vos identifiants de connexion :
Identifiant : <?= $user->email; ?>
Mot de passe : <?= $password ?>

Cordialement,
La boîte à pain
À bientôt.

+ 16
- 0
common/mail/cronRecapCommandes-html.php ファイルの表示

@@ -0,0 +1,16 @@

<?php
if(count($commandes)):
?>

<p>Bonjour,</p>
<p>Voici en pièce jointe le récapitulatif des <?= count($commandes) ?> commandes du <?= date('d/m',strtotime($date)) ?>.</p>
<p>À bientôt.</p>

<?php else: ?>

<p>Bonjour,</p>
<p>Vous n'avez aucune commande pour le <?= date('d/m',strtotime($date)) ?>.</p>
<p>À bientôt.</p>

<?php endif; ?>

+ 20
- 0
common/mail/cronRecapCommandes-text.php ファイルの表示

@@ -0,0 +1,20 @@

<?php
if(count($commandes)):
?>

Bonjour,

Voici en pièce jointe le récapitulatif des <?= count($commandes) ?> commandes du <?= date('d/m',strtotime($date)) ?>.

À bientôt.

<?php else: ?>

Bonjour,

Vous n'avez aucune commande pour le <?= date('d/m',strtotime($date)) ?>.

À bientôt.

<?php endif; ?>

+ 51
- 1
common/mail/layouts/html.php ファイルの表示

@@ -12,10 +12,60 @@ use yii\helpers\Html;
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
<style type="text/css">
body {
padding: 0px;
margin: 0px ;
font-family: Arial ;
font-size: 14px ;
background-color: white ;
}
a {
color: #BB8757 ;
}
#header {
background-color: #f8f1dd ;
border-bottom: 1px solid #e0e0e0 ;
height: 50px ;
text-align: center ;
}
#header .icon {
width: 70px ;
position: relative;
bottom: -17px ;
}
#content {
padding: 15px ;
background-color: white ;
}
#footer {
padding: 5px 15px ;
color: gray ;
border-top: dotted 1px #e0e0e0 ;
}
#link-boiteapain {
text-decoration: none ;
color: #BB8757 ;
}
</style>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<div id="header">
<img class="icon" src="http://www.laboiteapain.net/img/laboiteapain-mail2.png" alt="La boîte à pain" />
</div>
<div id="content">
<?= $content ?>
</div>
<div id="footer">
<p><a id="link-boiteapain" href="http://www.laboiteapain.net/">La boîte à pain</a> &bull; Plateforme de réservation de pain</p>
</div>
<?php $this->endBody() ?>
</body>
</html>

+ 4
- 0
common/mail/layouts/text.php ファイルの表示

@@ -8,5 +8,9 @@ use yii\helpers\Html;
<?php $this->beginPage() ?>
<?php $this->beginBody() ?>
<?= $content ?>

--
La boîte à pain / Plateforme de réservation de pain
http://www.laboiteapain.net/
<?php $this->endBody() ?>
<?php $this->endPage() ?>

+ 1
- 2
common/mail/passwordResetToken-html.php ファイルの表示

@@ -13,6 +13,5 @@ $resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 't

<p><?= Html::a(Html::encode($resetLink), $resetLink) ?></p>
<p>À bientôt,<br />
La boîte à pain</p>
<p>À bientôt.</p>
</div>

+ 1
- 2
common/mail/passwordResetToken-text.php ファイルの表示

@@ -11,5 +11,4 @@ Suivez le lien suivant pour réinitialiser votre mot de passe :

<?= $resetLink ?>

À bientôt,
La boîte à pain
À bientôt.

+ 27
- 0
common/mail/signup-html.php ファイルの表示

@@ -0,0 +1,27 @@
<?php

use yii\helpers\Html;
use common\models\User ;
use common\helpers\Url ;

?>

<p>Bonjour <?= Html::encode($user->prenom) ?>,</p>

<p>Votre inscription sur <strong>La boîte à pain</strong> a bien été prise en compte.</p>

<p>Voici votre identifiant de connexion : <br />
<strong><?= Html::encode($user->email) ?></strong></p>

<?php if($user->status == User::STATUS_BOULANGER): ?>
<p>Vous pouvez dès maintenant vous connecter à votre <a href="<?= Url::backend(); ?>">Espace boulanger</a> pour mettre
en place votre système de réservation.</p>
<?php else: ?>
<?php if(!is_null($etablissement)): ?>
<p>Vous pouvez maintenant <a href="<?= Url::frontend().'index.php?r=commande/create&id_etablissement='.$etablissement->id ?>">passer commande</a> dans votre boulangerie <strong><?= Html::encode($etablissement->nom); ?></strong>.</p>
<?php else: ?>
<p>Vous pouvez maintenant passer commande dans votre boulangerie.</p>
<?php endif; ?>
<?php endif; ?>

<p>À bientôt.</p>

+ 27
- 0
common/mail/signup-text.php ファイルの表示

@@ -0,0 +1,27 @@
<?php

use common\models\User ;
use common\helpers\Url ;

?>

Bonjour <?= $user->prenom ?>,

Votre inscription sur La boîte à pain a bien été prise en compte.

Voici votre identifiant de connexion :
<?= $user->email ?>

<?php if($user->status == User::STATUS_BOULANGER): ?>
Vous pouvez dès maintenant vous connecter à votre Espace boulanger pour mettre en place votre système de réservation :
<?= Url::backend(); ?>
<?php else: ?>
<?php if(!is_null($etablissement)): ?>
Vous pouvez maintenant passer commande dans votre boulangerie "<?= $etablissement->nom ?>" :
<?= Url::frontend().'index.php?r=commande/create&id_etablissement='.$etablissement->id ?>
<?php else: ?>
Vous pouvez maintenant passer commande dans votre boulangerie.
<?php endif; ?>
<?php endif; ?>

À bientôt.

+ 1
- 1
console/config/params.php ファイルの表示

@@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
'adminEmail' => 'contact@laboiteapain.net',
];

+ 1
- 1
frontend/config/params.php ファイルの表示

@@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'guillaume.bourgeois13@laposte.net',
'adminEmail' => 'contact@laboiteapain.net',
];

+ 24
- 3
frontend/controllers/SiteController.php ファイルの表示

@@ -77,6 +77,7 @@ class SiteController extends Controller

public function actionIndex()
{
// redirection de l'utilisateur vers le tableau de bord s'il est connecté
if(!Yii::$app->user->isGuest) {
return $this->redirect(['commande/index']) ;
@@ -162,9 +163,9 @@ class SiteController extends Controller
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
Yii::$app->session->setFlash('success', 'Votre message a bien été envoyé. Nous vous répondrons dès que possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending email.');
Yii::$app->session->setFlash('error', 'Il y a eu une erreur lors de l\'envoi de votre message.');
}

return $this->refresh();
@@ -186,7 +187,27 @@ class SiteController extends Controller
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
if (Yii::$app->getUser()->login($user)) {
//return $this->goHome();
$etablissement = null ;
if($model->id_etablissement)
{
$etablissement = Etablissement::findOne($model->id_etablissement) ;
}
Yii::$app->mailer->compose(
[
'html' => 'signup-html',
'text' => 'signup-text'
],
[
'user' => $user,
'etablissement' => $etablissement
])
->setTo($user->email)
->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain'])
->setSubject('[La boîte à pain] Inscription')
->send();
$this->redirect(['commande/index']) ;
}
}

+ 7
- 3
frontend/models/ContactForm.php ファイルの表示

@@ -54,11 +54,15 @@ class ContactForm extends Model
public function sendEmail($email)
{
return Yii::$app->mailer->compose()
return Yii::$app->mailer->compose([
'html' => 'contact-html',
'text' => 'contact-text'],
[ 'content' => $this->body,
'nom' => $this->name
])
->setTo($email)
->setFrom([$this->email => $this->name])
->setSubject($this->subject)
->setTextBody($this->body)
->setSubject('[La boîte à pain] Contact : '.$this->subject)
->send();
}
}

+ 0
- 17
frontend/models/SignupForm.php ファイルの表示

@@ -201,23 +201,6 @@ class SignupForm extends Model
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
// envoi d'un mail de confirmation
/*$message = "Bonjour,

Votre inscription sur le site de la boîte à pain a bien été prise en compte !

Ce compte vous permet de passer vos commandes directement sur le site internet.

Si vous avez des questions, n'hésitez pas à me contacter.

À bientôt,
Guillaume" ;
Yii::$app->mailer->compose()
->setTo($user->email)
->setFrom(['contact@laboiteapain.net' => 'Guillaume Bourgeois'])
->setSubject("Votre inscription sur la boîte à pain")
->setTextBody($message)
->send();*/
// on ajoute la boulangerie sélectionnée par l'user en favoris
if($this->option_client_boulanger == 'client')

バイナリ
frontend/web/img/laboiteapain-mail.png ファイルの表示

変更前 変更後
幅: 210  |  高さ: 210  |  サイズ: 4.1KB

バイナリ
frontend/web/img/laboiteapain-mail2.png ファイルの表示

変更前 変更後
幅: 250  |  高さ: 250  |  サイズ: 4.8KB

読み込み中…
キャンセル
保存