Laravel and Amazon SES - laravel

I am setting up Amazon SES for the first time. Following the documentation on Laravel website I have installed a package and started to set up mail.
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'ses'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
services.php
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'eu-west-1',
],
.env
MAIL_DRIVER=ses
SES_KEY=ASKFKGDRJ3
SES_SECRET=kdfsjjdsfjdfsjdfsj
MAIL_HOST=email.eu-west-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Mail/WelcomeEmail.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class WelcomeEmail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* #return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->from('test#gmail.com')
->view('emails.welcomeEmail');
}
}
welcomeEmail.blade.php
<p>This is a test email from test email address, let me know on slack if you receive it</p>
Controller:
public function map(Request $request)
{
Mail::to($request->user())->send(new WelcomeEmail());
return view('profile.map');
}
And error:
Error executing "SendRawEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.eu-west-1.amazonaws.com` resulted in a `403 Forbidden` response:
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>SignatureDo (truncated...)
SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/
aws-sdk-invocation-id:7a73507566587348bba7c543661be161
aws-sdk-retry:0/0
host:email.eu-west-1.amazonaws.com
x-amz-date:20170726T195108Z
aws-sdk-invocation-id;aws-sdk-retry;host;x-amz-date
7a1f353a7f93f014d66ee19fb4b9661a79fea8411d1f97af2799c0cc04dc57dc'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20170726T195108Z
20170726/eu-west-1/ses/aws4_request
c2422180627319d05721ed6a2dc3973f7a508c34e4b2f9699d0a7bbf0c56d6a8'
- <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/
aws-sdk-invocation-id:7a73507566587348bba7c543661be161
aws-sdk-retry:0/0
host:email.eu-west-1.amazonaws.com
x-amz-date:20170726T195108Z
aws-sdk-invocation-id;aws-sdk-retry;host;x-amz-date
7a1f353a7f93f014d66ee19fb4b9661a79fea8411d1f97af2799c0cc04dc57dc'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20170726T195108Z
20170726/eu-west-1/ses/aws4_request
c2422180627319d05721ed6a2dc3973f7a508c34e4b2f9699d0a7bbf0c56d6a8'
</Message>
</Error>
<RequestId>c458f296-723b-11e7-a686-515a08ffcc2f</RequestId>
</ErrorResponse>
However, I am sure that SES_key and secret is correct, domain is verified, and email also, what am I missing?

Yes, it not says that the email I am sending to is not verified?
This means you're in the SES "sandbox".
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html
During development:
You can only send mail to the Amazon SES mailbox simulator and to verified email addresses and domains.
You can only send mail from verified email addresses and domains.
You can send a maximum of 200 messages per 24-hour period.
Amazon SES can accept a maximum of one message from your account per second.
Moving from sandbox to production (where you can send email to anyone) is easy enough - just fill out the form at https://aws.amazon.com/ses/extendedaccessrequest/.

it's means your in sandbox mode and in sandbox mode only verified email get maild so either move from sandbox to production or verify your mail for testing mail but at last you have to move in production

Related

Mail Error:- Failed to authenticate on SMTP server with username "support#myDomain.io" using 3 possible authenticators

Google mail is running perfectly for sending mail but domain-mail (support.myDomain.io) returns following errors
Swift_TransportException Failed to authenticate on SMTP server with username "support#xamer.io" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials o28-20020aa7979c000000b005809a3c1b6asm11901153pfp.201 - gsmtp ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials o28-20020aa7979c000000b005809a3c1b6asm11901153pfp.201 - gsmtp ". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials o28-20020aa7979c000000b005809a3c1b6asm11901153pfp.201 - gsmtp ".
env code :-
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=support#myDomain.io
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=support#myDomain.io
MAIL_FROM_NAME="${APP_NAME}"
controller code :-
Mail::to($data->email)->send(new EmailVerify($data));
app/Mail/EmailVerify.php :-
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class EmailVerify extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* #return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->subject('Email from '.env('APP_NAME'))->view('mail.emailVerify')->with(['data' => $this->data]);
}
}
config/mail.php :-
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
when I am using google mail with same code is running perfectly
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mymail.gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=mymail.gmail.com
MAIL_FROM_NAME="${APP_NAME}"
I am trying to send mail from my domain email (support#myDomain.com) in laravel.
I googled it a lot, but could not find a proper answer. I would be very glad if any of you can help me.
Did you turn on the "Allow less secure apps" on? if not go to this link
https://myaccount.google.com/security#connectedapps
Look at the Sign-in & security -> Apps with account access menu.
You must have to turn the option "Allow less secure apps" ON.
If it still doesn't work try one of these:
Go to https://accounts.google.com/UnlockCaptcha , and click continue and unlock your account for access through other media/sites.
Use double quote in .env your password: "your password"
also don't forget to clear the cache
php artisan config:clear

CORS ORIGIN problem, In a Laravel project

I have a problem with cors origin in my laravel project, I created cors.php in middwares folder and I declare it in Kernel.php and app/Providers/RouteServiceProvider.php as well... I did everything to solve it in my Laravel project, even in folder config I added a file Cors.php
I'm now wondering if I have to add something in Nginx configuration or Apache configuration ?
I'm hosting my project in hostinger VPS, The version of linux is ubuntu 22.04.5 LTS
Thank you in advance.
Regards
Middlewares/Cors.php
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
*
* #param \Illuminate\Http\Request $request
* #param \Closure $next
* #return mixed
*/
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
}
}
config/cors.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*','web/*', 'sanctum/*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => ['*'],
'allowed_headers' => ['*'],
'exposed_headers' => ['*'],
'max_age' => 0,
'supports_credentials' => true
];
I added also this lines to Http/kernel.php
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'cors' => \App\Http\Middleware\Cors::class, // added
];
I in console I have this message ( see pictures ):
and I have this message in console : Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
post.js:42559 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
scrollspy.js:224 Uncaught TypeError: Cannot read properties of null (reading 'classList')
at An._activate (scrollspy.js:224:10)
at An._process (scrollspy.js:191:14)
at new An (scrollspy.js:80:10)
at bg_scripts.js:35:9
sb-forms-latest.js:5 Uncaught Error: GET_ELEMENTS: -> form[data-sb-form-api-token]
at e (sb-forms-latest.js:5:415)
at sb-forms-latest.js:5:3777
profile.js:32882 Error: Network Error
at createError (profile.js:872:15)
at XMLHttpRequest.handleError (profile.js:754:14)
127.0.0.1:8000/getMessages:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
boxicons.min.css:1 Failed to load resource: the server responded with a status of 404 ()
[enter image description here][1]
[enter image description here][2]
[1]: https://i.stack.imgur.com/T9DhM.png
[2]: https://i.stack.imgur.com/7zXtW.png
are you Building an API with a SPA ?
and he will be better if you have some error just provide us.
No Problem, Create a new Middleware and put this line in it:
$response = $next($request);
$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set('Access-Control-Allow-Methods', '*');
$response->headers->set('Access-Control-Allow-Credentials', true);
$response->headers->set('Access-Control-Allow-Headers', 'X-Requested-With,Content-Type,X-Token-Auth,Authorization');
return $response;
and your problem will be solved
You Can check this repo for more details

Laravel 9 Symfony mailer not working - mail sent from app but not received in gmail

In Laravel 8 I was able to send an email verification email. And now in Laravel 9 email sent message appears but I don't receive an email.
I have used my correct mail host provided by domain with port, username, and password as previously and checked enough times. I have also changed ssl to tls but no success.
.env file
MAIL_MAILER=smtp
MAIL_HOST=mail.getalow.com
MAIL_PORT=465
MAIL_USERNAME=********
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS="support#getalow.com"
MAIL_FROM_NAME="${APP_NAME}"
I also added 'verify_peer' => false in mail.php config file but no success.
mail.php
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'verify_peer' => false, // <------ IT HAS TO BE HERE
],
my User.php model also has implements MustVerifyEmail as I do everytime.
class User extends Authenticatable implements MustVerifyEmail
In registration controller event(new Registered($user)); is presented
RegistrationController.php
// Register a new user
public function register(RegistrationRequest $request) {
$user = User::create($request->validated())->assignRole(['User', 'Commenter']);;
event(new Registered($user));
Auth::login($user);
return to_route('home')
->with(Helpers::Toast(
'Welcome ' . $user->name,
'Your account has been created.',
'success',
'5000'
));
}
I tried it from localhost to mailtrap it works. But when I upload it to server with all details of server in env file as above. I receive success message as in registration controller, but I don't receive activation email on my registered email.
I am using shared hosting, cpanel as hosting provider
What am I missing please help. I stucked on it for 4 days.
You said you are using cPanel shared hosting server.
There is no problem in your Laravel 9 code. The problem is on your DNS setting of your email in cPanel. You have to change CNAME, MX, TXT records on cPanel as provided by your hosting provider.
For example:
If you are using ohodomain hosting provider.
Go to account settings.
Select your domain from list of your domains.
Go to Manage Email.
There you will see the error with its solution that you have to solve.
Add the provided CNAME, MX, TXT records on your cPanel's Zone Editor.

Mailer Error: SMTP Error: Could not connect to SMTP host

How to resolve this error? I do all possible things to resolve this issue but it cannot resolve. Here is my .env file code
MAIL_DRIVER=smtp
MAIL_HOST=fluorine.cloudhosting.co.uk
MAIL_PORT=465
MAIL_USERNAME=contacts#cleansafeltd.com
MAIL_PASSWORD=Hggjgjgghv123
MAIL_ENCRYPTION=ssl
Here is the code of mail.php.
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'fluorine.cloudhosting.co.uk'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'contacts#cleansafeltd.com'),
'name' => env('MAIL_FROM_NAME', 'Contact'),
],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Here is the mailController
public function sendMail($to_email, $template_id, $users_insertId = 0) {
set_time_limit(0);
$mail = new PHPMailer(true);
$mail->IsSendmail();
$mail->IsSMTP(true);
$mail->Host = "fluorine.cloudhosting.co.uk";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "website#cleansafeltd.com";
$mail->Password = "Star9000!";
$mail->Port = "465";
$mail->IsHTML(true);
}
I do all thin with tls or port 587 also but not solved.
Using your credentials (by the way, you shouldn't post your password in public places, you better change it), I was able to send myself a mail using the following code
Mail::to('mymail#domain')->send(new \App\Mail\TestMail);
\App\Mail\TestMail is a Mailable class, defined as follows
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class TestMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* #return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* #return $this
*/
// Optional params are commented out.
// replyTo changes the address one gets when clicking the reply button
public function build()
{
return $this->from(env('MAIL_USERNAME'), 'An alias name')
// ->to('mail#domain', 'alias name for recipient')
// ->cc('mail2#domain', 'alias name for cc')
// ->bcc('mail3#domain', 'alias name for bcc')
// ->replyTo('mail4#domain', 'alias for replyTo')
->subject('This is a test')
->view('mails.sample_mail'); // This is a laravel view.
}
}
Try this one:
Setup your gmail account
Go to settings -> Forwarding and POP/IMAP
- Check -> POP download: Enable POP for all mail (even mail that's already been downloaded)
- Check -> IMAP access: Enable IMAP
- Save
Go to Google Account -> security -> Less secure app access
Set to on instead of off
Set this to your .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=your email username
MAIL_PASSWORD=your email password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your email address
MAIL_FROM_NAME=Your email name
Now you can send email with your smtp gmail account

Sending Email with mailgun in laravel error

Hello i've been simply trying to send an email in laravel i read the documentation and they made it seem so easy but whenever i try i keep getting error after error, i tried sendgrid didn't work and now i'm trying to use mailgun but i'm having issues with it as well.
This is my code::
$data = array();
Mail::send('emails.auth.activate', $data, function($message)
{
$message->to('xxxxxxxxx#gmail.com', 'John Doe')->subject('This is a demo!');
});
This is the error i get:
GuzzleHttp \ Exception \ ClientException (400)
Client error response [url] https://api.mailgun.net/v2/mail.xxxxxxx.com/messages.mime [status code] 400 [reason phrase] BAD REQUEST
Mail Config:
<?php
return array(
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => 'mailgun',
'host' => 'sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org',
'port' => 587,
'from' => array('address' => 'mail#xxxxxx.com', 'name' => 'Xxxxxxxx'),
'encryption' => 'tls',
'username' => 'xxxxxxx#gmail.com',
'password' => 'xxxxxxxxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => true,
);
Follow these steps
First of all, install guzzle package by adding "guzzlehttp/guzzle": "~4.0" line inside composer.json
Update composer using composer update
Create your account on mailgun from http://www.mailgun.com/. After creating account, kindly note the mail gun subdomain created like sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org and API key created like key-65c33f1xxxxxxxxxxxxxxxxxxxx
Go to config/services.php file and replace
'mailgun' => array(
'domain' => '',
'secret' => '',
),
with
'mailgun' => array(
'domain' => 'sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org',
'secret' => 'key-65c33f1xxxxxxxxxxxxxxxxxxxx',
),
If you want to create your own sub-domain, you can create and assign to domain (as an alternative)
Configure config/mail.php like this
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => array('address' => 'mail#xxxxxx.com', 'name' => 'Xxxxxxxx'),
'encryption' => 'tls',
'username' => null,
'password' => null,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false
Note that you do not need to supply username and password for this. Mailgun will handle this.
Try sending email now. Hope this helps. Good luck!
Just wanted to add one possible reason for the error. I received this error while using sandbox mode when I hadn't set the authorized recipient yet. When I logged into Mailgun and added the intended recipient to the "Authorized Recipient" list the error went away.
I had the same issue and kept getting the following error:
Client error response [url] https://api.mailgun.net/v3//messages.mime 404 not found
There isn't much written about this error written online for Laravel 5.1 which I'm using. It turns out that in the config->services the default Laravel 5.1 installation comes with :
'domain' => env('');
'secret' => env('');
for some reason if you keep your domain and secret wrapped in env as per default installation, the MailGunTransport doesnt pick it up. So just set it to the following:
domain' =>'yourdomain';
'secret' => 'yoursecret';
Hope this helps since I'm sure i'm not the only one who probably run into this issue.
I had this problem as I hadn't activated my mailgun account. Once activated all worked fine
I also stucked once in configuring the Mailgun in Laravel 5.1 and what worked for me is the following process. Hope its helps someone:
1) Install guzzle package by adding "guzzlehttp/guzzle": "5.0" line inside composer.json like this:
"require": {
"guzzlehttp/guzzle": "~5.0"
},
2) Update composer using sudo composer update in the terminal.
3) Restart Apache.
4) Create the account in http://www.mailgun.com. It will create a Sub Domain and API Key.
5) Add the Sub Domain and API Key in the .env like this:
MAILGUN_DOMAIN=sandbox8...........3b.mailgun.org
MAILGUN_SECRET=key-9..................04
6) And in the services.php add these line:
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
7) Now the mail.php as follows:
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => ['address' => null, 'name' => null],
'encryption' => 'tls',
'username' => null,
'password' => null,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
I hope this works for you all.
You will be able to send mail to the persons in the same domain unless you have added them in the authorised recipient category.
If you add someone to authorised recipient category then he/she would have to approve the request and then only would be able to receive the emails.

Resources