Laravelda FROM va REPLYTO manzillarini o'zgartirish 5.4

FROM va javob berish uchun foydalanuvchi manzilini elektron pochta orqali yubora olmayman

FormRequest'da:

    public function persist()
{
    $reservation = Resa::create(
        $this->only(['nom', 'email', 'phone', 'formule', 'date_arr', 'date_ret', 'nb_adu', 'nb_enf', 'lemessage'])
    );
    Mail::to('[email protected]')
    ->from($reservation->email, $reservation->nom)
    ->replyTo($reservation->email, $reservation->nom)
    ->send(new Reservation($reservation));

}

Xatolik bor:

FatalThrowableError in ReservationForm.php line 48:
Call to undefined method Illuminate\Mail\PendingMail::from()

Imkoniyat bilan to'la harakat qildim, lekin men FROM va REPLYTO maydonlarini o'zgartira olmayman Menga yordam bera olasizmi ? Rahmat

4

7 javoblar

Mail Facade answerTo() usulini endi amalga oshirmaydi. Buning o'rniga, bu usul Mailable sinfining o'zi uchun ko'chirildi. Rasmiy hujjatlar hujjatlarni o'rnatish uchun build() usulidan foydalanishni taklif qiladi, ammo bu har doim ham qulay emas (masalan, javob berish maydoni har doim har xil bo'lishi mumkin)

Ammo siz hali ham shunga o'xshash sintaksidadan foydalanishni xohlasangiz:

$mailable = new myMailableClass;
$mailable->replyTo('[email protected]');

Mail::to('[email protected]')
  ->send($mailable);

For a complete list of available methods on the Mailable class see the Mailable Documentation

7
qo'shib qo'ydi

Mail Facade answerTo() usulini endi amalga oshirmaydi. Buning o'rniga, bu usul Mailable sinfining o'zi uchun ko'chirildi. Rasmiy hujjatlar hujjatlarni o'rnatish uchun build() usulidan foydalanishni taklif qiladi, ammo bu har doim ham qulay emas (masalan, javob berish maydoni har doim har xil bo'lishi mumkin)

Ammo siz hali ham shunga o'xshash sintaksidadan foydalanishni xohlasangiz:

$mailable = new myMailableClass;
$mailable->replyTo('[email protected]');

Mail::to('[email protected]')
  ->send($mailable);

For a complete list of available methods on the Mailable class see the Mailable Documentation

7
qo'shib qo'ydi

Laravel 5.4 Mailables-da, replyTo , mavzu , cc , bcc va boshqalar pochta orqali yuborilishi mumkin. Build usulini tanlang. Bu, shuningdek, pochta jabhasida ham o'rnatilishi mumkin bo'lgan dan uchun ham amal qiladi.

Quyida bir qator atributlardan foydalangan holda aloqa formasini jo'natishning oddiy misoli:

Siz ni statik usulidan to'g'ridan-to'g'ri Mail jabhasini to'g'ridan-to'g'ri ishlatishingiz mumkin, lekin bunga misol qilib, uni pochta orqali yuborish mumkin:

Mail::send(new ContactCompany($attributes));

Keyin build usulida answerTo ni o'rnating:

class ContactCompany extends Mailable
{
    use Queueable, SerializesModels;

    public $attributes;

    /**
     * Create a new message instance.
     *
     * @param $attributes
     */
    public function __construct($attributes)
    {
        $this->attributes = $attributes;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $this->to($this->attributes['departmentEmail'], config('app.name'));
        $this->replyTo($this->attributes['email'], $this->attributes['name']);
        $this->subject(sprintf("New contact message from %s", $this->attributes['name']));

        return $this->markdown('emails.contact.company');
    }
}

Mail :: send() ni o'rnatish uchun always:() va always :: Mail() dan va barcha e-pochtalarining answerTo ga javob bering, shuning uchun ularni diqqat bilan ishlatish kerak.

2
qo'shib qo'ydi

Laravel 5.4 Mailables-da, replyTo , mavzu , cc , bcc va boshqalar pochta orqali yuborilishi mumkin. Build usulini tanlang. Bu, shuningdek, pochta jabhasida ham o'rnatilishi mumkin bo'lgan dan uchun ham amal qiladi.

Quyida bir qator atributlardan foydalangan holda aloqa formasini jo'natishning oddiy misoli:

Siz ni statik usulidan to'g'ridan-to'g'ri Mail jabhasini to'g'ridan-to'g'ri ishlatishingiz mumkin, lekin bunga misol qilib, uni pochta orqali yuborish mumkin:

Mail::send(new ContactCompany($attributes));

Keyin build usulida answerTo ni o'rnating:

class ContactCompany extends Mailable
{
    use Queueable, SerializesModels;

    public $attributes;

    /**
     * Create a new message instance.
     *
     * @param $attributes
     */
    public function __construct($attributes)
    {
        $this->attributes = $attributes;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $this->to($this->attributes['departmentEmail'], config('app.name'));
        $this->replyTo($this->attributes['email'], $this->attributes['name']);
        $this->subject(sprintf("New contact message from %s", $this->attributes['name']));

        return $this->markdown('emails.contact.company');
    }
}

Mail :: send() ni o'rnatish uchun always:() va always :: Mail() dan va barcha e-pochtalarining answerTo ga javob bering, shuning uchun ularni diqqat bilan ishlatish kerak.

2
qo'shib qo'ydi

E-pochtalarni yuborishning afzal usullari endi mailables"> mailables va siz javob yozishingiz va javob berishingiz mumkin.() yoki answerTo() usullaridan foydalanish.

Biroq, always va alwaysReplyTo usullaridan foydalanishga harakat qiling. Biroq, bunday elektron maktubni yuborganingizdan so'ng, ushbu o'zgarishlarda hech qanday elektron pochtaga hech qanday ta'sir ko'rsatmasligiga ishonch hosil qilish uchun avvalgi qiymatlarni qayta tiklashingiz kerak.

Lekin metodik usullarga qaraganda, u eng yaxshi echim bo'lmasligi mumkin, chunki pochta orqali ma'lumotlarga qarash va ularni Laravelning so'nggi versiyalarida elektron pochtani yuborish uchun foydalanish.

0
qo'shib qo'ydi

Problem resolved. I edit app>Mail>Reservation.php

    public function build()
    {
//      return $this->markdown('emails.reservation-email');
        return $this->from($this->reservation->email)->markdown('emails.reservation-email');
    }

app>Http>Request>ReservationForm.php

public function persist()
{
    $reservation = Resa::create(
        $this->only(['nom', 'email', 'phone', 'formule', 'date_arr', 'date_ret', 'nb_adu', 'nb_enf', 'lemessage'])
    );
    Mail::to('[email protected]')->send(new Reservation($reservation));
}
0
qo'shib qo'ydi

Problem resolved. I edit app>Mail>Reservation.php

    public function build()
    {
//      return $this->markdown('emails.reservation-email');
        return $this->from($this->reservation->email)->markdown('emails.reservation-email');
    }

app>Http>Request>ReservationForm.php

public function persist()
{
    $reservation = Resa::create(
        $this->only(['nom', 'email', 'phone', 'formule', 'date_arr', 'date_ret', 'nb_adu', 'nb_enf', 'lemessage'])
    );
    Mail::to('[email protected]')->send(new Reservation($reservation));
}
0
qo'shib qo'ydi
Laravel Uzbek Community
Laravel Uzbek Community
172 ishtirokchilar