Laravel send mail with MailGun - php

i install guzzle for sending mail with mailgun, i create mailgun account
this is my mail.php
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => array('address' =>'my#gmail.com','name'=>'My Name'),
'encryption' => 'tls',
'username' => null,
'password' => null,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
and my services.php
'mailgun' => [
'domain' => 'sandboxexxxxxxxxxxxxxxxxxxxxx.mailgun.org',
'secret' => 'key-xxxxxxxxxxxxxxxxxxxxxxx',
],
but i get error, i have setting it right, but what is the problem?
ClientException in Middleware.php line 69:
Client error: 401

Related

laravel Process could not be started [Le chemin d'acc�s sp�cifi� est introuvable. when send mail

I use flutter for developement mobile application and in backend I use laravel, now when I try to register user then send mail I found this error in send mail.
Process could not be started [Le chemin d'acc�s sp�cifi� est introuvable.
code .env:
MAIL_DRIVER= smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=my gmail
MAIL_PASSWORD=my password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=my gmail
MAIL_FROM_NAME="${APP_NAME}"
code mail.php:
'mailers' => [
'smtp' => [
'driver' => env('MAIL_DRIVER', 'smtp'),
'transport' => 'mail',
'host' => env('MAIL_HOST', 'smtp.googlemail.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',
],
],
how to resolve this error and thanks.
if someone has such error in the the future i fixed it that way :
go to the file vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php and comment out the code $options = []; and paste the code $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);

What's the correct configuration to send emails using Sendmail in Laravel?

I am using Laravel 7 and I want to send an email using the Sendemail driver via Laravel Mail facade. It worked when I used the PHP mail function but I want to use the Laravel Mail facade instead.
My .env file email configuration:
MAIL_DRIVER=sendmail
MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'
My default mail setup in config/mail.php:
'default' => env('MAIL_MAILER', 'sendmail'),
'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'),
],
'ses' => [
'transport' => 'ses',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
I have created Mail class as explained in the docs. What is the right configuration to make it work?
First, change the default MAIL_MAILER to use Sendmail.
MAIL_MAILER=sendmail
Then in config/mail.php, update the Sendmail line.
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL', '/usr/sbin/sendmail -bs')
],
Finally, if you need to change the MAIL_SENDMAIL value then add this line to your .env.
MAIL_SENDMAIL='/usr/sbin/sendmail -t -i'

Laravel, Failed to authenticate on SMTP server with username "" using 3 possible authenticators

I am trying to find out why this happens.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*******t#gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******#gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('******#gmail.com'),
'password' => env('******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
This is the error
Failed to authenticate on SMTP server with username "" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportExce ▶
534-5.7.14 GVHg3-rU8SDpVLdwnIPviBCjKNnBRcxuU2N3-pcUWd0TeMbM_vULrHhQcVNXjhoewjrquW\r\n
534-5.7.14 Jttd6jNXfnledZiAMv-rjMvpnd01nas-2J2BYU_Krd4kzT-YmTR_HW9uW3S6Ts2jUxDaC8\r\n
534-5.7.14 XmT_TV9QqYXHXkTMcrX3OG9D4QyF4E6w7fwnu2bYZT36rZXTU-HqJwlWzJBv8-MC2P9xrN\r\n
534-5.7.14 cUd4-BirG0rfAjlDxy5bkbon3S_bIFSZQVd0-5wskctUR4do7F> Please log in via\r\n
534-5.7.14 your web browser and then try again.\r\n
534-5.7.14 Learn more at\r\n
534 5.7.14 https://support.google.com/mail/answer/78754 l5-v6sm1366079wrv.84 - gsmtp\r\n
" in C:\xampp\htdocs\wer\walrer\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:457\n
Stack trace:\n
I checked email credentials and they are the same. In this project I
have used authentication , but can't find a solution to this one.
I think there is something wrong with your mail.php file.
You should be passing the variable names to the env() function for username and password.
So this:
'username' => env('******#gmail.com'),
'password' => env('******'),
Becomes this:
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
Your .env file looks good.
You mail.php file should look like this:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******#gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', '******#gmail.com'),
'password' => env('MAIL_PASSWORD', '******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
The value in the second parameter for the env() function, gets used if the .env key specified in the first parameter is not found.
You need to enable less secure apps access at your google account for this to work

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required

I am trying to send an email verification for the registering users but I am getting the following error:
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required. Learn more at\r\n 530 5.5.1
https://support.google.com/mail/?p=WantAuthError v11sm5345109pgt.0 -
gsmtp\r\n
I have tried all the possible ways by enabling the "less secure" and other instructions but not understanding the error. please help me to sort out the problem.
My .env file is :
My Controller:
My mail.php:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => env('MAIL_FROM_ADDRESS', 'myaccount#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'), ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('myaccount#gmail.com'),
'password' => env('*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
The problem is in your mail.php, use this code instead of your
...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myaccount#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example')
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'myaccount#gmail.com'),
'password' => env('MAIL_PASSWORD', '*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
...
EDIT:
First parameter of the env() helper method is name of environment variable and second one is a fallback value if that variable isn't found. The reason why it didn't work is because Laravel wasn't able to find an environment variable under the name myaccount#gmail.com and *******.

Laravel 4.2 email configuration with mail driver on local

i'm using xampp and want to send email with laravel 4.2 mail driver on local machine. But nothings happen. somebody can help?
return array(
'driver' => 'mail',
'host' => 'localhost',
'port' => 25,
'from' => array('address' => 'foo#bar.com', 'name' => 'foo'),
'encryption' => 'tls',
'username' => '',
'password' => '',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);

Categories