I
I
Islam Ibakaev2018-10-17 20:55:05
Laravel
Islam Ibakaev, 2018-10-17 20:55:05

How to set up sending mail through the postal address on the server in laravel application?

For example, you have a website yoursite.ru and, accordingly, you have mail, for example, [email protected]
So, how can you send messages through it? What to include in . env (as far as I understand, the driver is mail)

MAIL_DRIVER=mail
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=

Here is the code to send a callback. Under mailtrap (configured for local development), it works fine, and under mail , a server error 500 error occurs .
public function callback (Request $request) {

    $this->validate($request, [
      'name' => 'required|min:1',
      'tel' => 'required',
    ]);
    
    Mail::send('emails.callback', [
      'tel' => $request->tel,
      'name' => $request->name
    ], function($mail) use($request) {
      $mail->from('[email protected]', $request->name);
      $mail->to('[email protected]')->subject('Обратный звонок');
    });

    return response()->json([
      'message_sent' => 'Заявка принята! Скоро мы с вами свяжемся!'
    ]);
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2018-10-17
@AXP-dev

Turn on debug APP_DEBUG=trueand see more.
PS
This package is required to be installed - https://github.com/barryvdh/laravel-debugbar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question