Answer the question
In order to leave comments, you need to log in
Why do two emails come from one yii2 form?
Two letters began to arrive instead of one
yiiframework.ru/forum/viewtopic.php?t=21446 - I tried it, but nothing seems to change
Implemented through widgets
One model is responsible for all sending
public function contact($email)
{
if($this->...){
$message = "Имя: {$this->name}\nEmail или телефон: {$this->phone}\nСообщение: {$this->body}\n\nСообщение с сайта: {$this->url_site}";
if ($this->validate()) {
Yii::$app->mailer->compose()
->setTo([
// ..
])
->setFrom([$this->email => $this->name])
->setSubject($this->subject."ъзъх")
->setTextBody($message)
->send();
return true;
}
}
return false;
}
<?php
namespace app\components;
use Yii;
use yii\base\Widget;
use app\models\ContactForm;
class FBFWidget extends Widget
{
public function run()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
}
return $this->render('fbfWidget', [
'model' => $model,
]);
}
}
Answer the question
In order to leave comments, you need to log in
A similar problem can occur in the Google Chrome browser if the favicon.ico file is missing in the root of the site.
About this problem on Habré
It is treated either by adding a favicon.ico file or by setting htaccess
I have the same story stuck on the background of inactivity.
Button in JS:
$('#formvopros').submit(function(s){
if($('#bloxa').val()){
$('.text_voprosa').css({'background-color':'rgba(171, 220, 255,.7)'});
s.preventDefault();
var b = $(this);
$.ajax({
type: "POST",
url: "obr_vopros.php",
data: b.serialize(),
success: function() {
vi_4.fadeOut();
vi_5.animate({'top':'50%'},1000);
setTimeout(funpris,5000);
}
});
} else{
$('.iitog p').html('Укажите действительные данные');
$('.text_voprosa').css({'background-color':'rgba(250, 2, 2,.5)'});
s.preventDefault();
}
});
<p class="vopros on_5"><input type="submit" class="bot in_5" valur="Отправить"></p>
mail("[email protected]","Заказан просчет стоимости ремонта","Содержание сообщения:".$telo,"From: [email protected] \r\n");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question