Laravel with Mailgun setup -
i'm having troubles setting mailgun laravel. keep getting following message:
clientexception in requestexception.php line 111: client error: `post https://api.mailgun.net/v3//messages.mime` resulted in ` 404 not found` response: <!doctype html public "-//w3c//dtd html 3.2 final//en"> <title>404 not found</title> <h1>not found</h1> <p>the requested (truncated...)
not sure do. here basic setup followed:
the .env file
mail_driver=mailgun mail_host=smtp.mailgun.org mail_port=587 mail_username='sandbox8e8c3965d4d14cac9d4f346c3d******' mail_password='e662ad1bbef5efd44cb96d32d6******' mail_encryption=tls
the config/mail.php file
'driver' => env('mail_driver', 'mailgun'), 'host' => env('mail_host', 'smtp.mailgun.org'), 'port' => env('mail_port', 587), 'from' => [ 'address' => 'west**********@gmail.com', 'name' => 'my name here', ], 'encryption' => env('mail_encryption', 'tls'), 'username' => env('mail_username'), 'password' => env('mail_password'), 'sendmail' => '/usr/sbin/sendmail -bs',
my route file contains following
route::post('sendmail', function(\illuminate\mail\mailer $mailer, \illuminate\http\request $request) { $title = $request->title; $content = $request->content; $mailer->to('westtexascentral@gmail.com')->send(new \app\mail\mymailer($title, $content)); return 'mail sent.'; });
and mailer class contains following:
public $title; public $content; /** * create new message instance. * * @return void */ public function __construct($title, $content) { $this->title = $title; $this->content = $content; } /** * build message. * * @return $this */ public function build() { return $this->from('kaley36_aw@yahoo.com')->view('emails.mail'); }
i'm hoping on looked simple, hardest things solve sometimes, helpful. thank you.
if want use mailgun driver (using mailgun through api), have set mailgun's secret , domain on config/services.php
:
'mailgun' => [ 'domain' => 'your-mailgun-domain', 'secret' => 'your-mailgun-key', ],
and don't forget install required guzzle
package. open terminal , run:
composer require guzzlehttp/guzzle
if you're using mailgun through api, make sure line set on .env
file:
mail_driver=mailgun
and can ignore following directive on .env
file. use if you're using smtp protocol:
mail_host=smtp.mailgun.org mail_port=587 mail_username='sandbox8e8c3965d4d14cac9d4f346c3d******' mail_password='e662ad1bbef5efd44cb96d32d6******' mail_encryption=tls
hope help!
Comments
Post a Comment