Laravel email sends only in debug mode - laravel

I hope someone can help me. Searched every combination for this issue.
I have an Laravel (5.4) app for invoicing. Its called Akaunting. App domain is app.mydomain.com
Everything works fine, except it doesn't sends email to customers when debug mode is off.
My .env file is setup properly.
Previousely I received maximum size exceeded, but only debug mode as well. Thats now sorted by increasing upload_max_filesize = 254M and post_max_size = 254M
I've tried mail_driver=log the email with success. First line production.DEBUG: Message-ID: <3369a7418b3f17c887fd27888ebe9f12#app.mydomain.com>
My .env looks like this and the emails are not send unless in debug mode:
APP_NAME=Akaunting
APP_ENV=production
APP_LOCALE=en-GB
APP_INSTALLED=true
APP_KEY=MySecureKey
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_SCHEDULE_TIME="09:00"
DB_CONNECTION=mysql
DB_HOST=mysql.host.com
DB_PORT=3306
DB_DATABASE=akaunting_db
DB_USERNAME=akunting_usr
DB_PASSWORD=MyDbPassword
DB_PREFIX=gvf_
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
# QUEUE_DRIVER=database
# QUEUE_DRIVER=sync
MAIL_DRIVER=SMTP
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=GmailAppPassword
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="My App"
MAIL_FROM_ADDRESS=info#myapp.com
Thanks for your support.

Related

Emails sent using SMTP Gmail don't get delivered

I'm trying to send mails from my webserver using Laravel 6 like this:
Mail::send('feedback', ['email' => $email, 'text' => $text], function($message) use ($receiver)
{
$message->to($receiver, 'The receiver')->subject('New Feedback');
});
I added my login information into my .env file according to this page from google:
https://support.google.com/mail/answer/7126229?hl=de
my .env file:
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxx#gmail.com
MAIL_PASSWORD=my_gmail_login_password
MAIL_ENCRYPTION=tls
but my mails don't get sent/delivered. I don't get any error message or anything logged. Everything seems to be working, but for some reason they don't get delivered.
I tried it with enabling insecure apps in my gmail settings and using my gmail password and also with creating an app password and using the app password. Both options didn't work.
Does someone have an idea what I'm doing wrong?
Try changing .env variables as below:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
or
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
You should set the .env attribute as below
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Give it a try.

send email in laravel 5.4

I Want to send reset password email in laravel,with default laravel auth
first login in mailtrap.io and get username and password,then edit env file such as this:
MAIL_DRIVER=sendmail
MAIL_HOST=mail.moallemmarket.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
and edit mail.php file such as env,Now I receive We have e-mailed your password reset link! message But don't receive any email in my inbox,I changed ports to 25 ans 2525 But result is same.How I can Solved this problem?
I had no problem coding
The problem with the non-activation of the email was in the cpanel that was solved by sending the ticket
With mailtrap, I use these vars in my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null

Error occurring in sending mail for Forget password

I have set up laravel 5.6 on server. When I try to use Forget Password, I am gettting error after enter email id:
Class Swift_AddressEncoder_IdnAddressEncoder does not exist
actually, it was working find two days before but now i dont know what happen...I have done thing in it.
below connection in .env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=SG.EcuUbtbhSbq1IAh**1tPQg.uFah8Jw**7lh10wGpA_CPU01ySmAC26HFylz_BFI
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="Your Trade Log"
MAIL_FROM_ADDRESS=support#y**r**r*a**.com
this is live link for Reset Password: YourTradeLog

Laravel 5 send mail in contact form

I use Laravel 5.1 and want to send the admin of the page a mail with the content of a contact form.
In my .env file I added the following lines:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=admintest#gmail.com
MAIL_PASSWORD=adminpassword
MAIL_ENCRYPTION=tls
In my controller I have the following:
Mail::send('Site::email', ['contactObject' => $contactObject], function ($message) use ($contactObject) {
$message->from($contactObject->email, $contactObject->vorname)->subject('New contact!');
$message->to('admintest#gmail.com');
});
$contactObject == contains the form which was filled out in the form from the user
Desired result:
When admintest#gmail.com receive a email, the sender of the mail should be $contactObject->email
Actual result:
When admintest#gmail.com receive a email, the sender of the mail is admintest#gmail.com
Any ideas what goes wrong? Thank you
Try This:
In Live server you have no need to configure any type of mail service.
You have to just use this:
MAIL_DRIVER=mail
AND remove this code:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=admintest#gmail.com
MAIL_PASSWORD=adminpassword
MAIL_ENCRYPTION=tls
You have to just use in .env file:
MAIL_DRIVER=mail
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xyz#gmail.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
After change in .env file, restart service, or use command php artisan config:cache and php artisan config:clear.
Have you configured the global from address in the config?
Specifically here: https://github.com/laravel/laravel/blob/master/config/mail.php#L49
Chances are that you've set that and it's just using that, making these values blank should let you override it.
Failing that, because you're using Gmail to send an email to Gmail, it's likely not letting you spoof the from and is indeed a security feature on their end.

Mail::send() returns zero and no errors, still no mail sent

I'm trying to send my first email using L5.1 and Gmail account. I have 2-steps verification and I'm using specific app password in my .env file. When I try to send the email with:
$result =Mail::send('emails.contact', $request->all(), function($msg)
{
$msg->subject = 'Mail from Contact Page';
$msg->to = 'contact#fakedomain.com';
}); dd($result);
Then $result is always zero and no mail is sent (I checked the spam folder 1000 times). I also tried using mailtrap.io with credentials supplied and still the result is the same in browser and also using Tinker.
Here's my .env file:
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=127.0.0.1
DB_DATABASE=pandora
DB_USERNAME=myDatabaseUser
DB_PASSWORD=myDatabasePassword
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=myUser#gmail.com
MAIL_PASSWORD=AppSpecificPassword
MAIL_ENCRYPTION=ssl
I also authorized the app in Gmail settings.
Any thoughts?
This is my .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=asd#gmail.com
MAIL_PASSWORD=emailpassword
MAIL_ENCRYPTION=tls
Follow this
I found the answer in this post
SO, I change mi code to:
$result = Mail::send('emails.contact',$request->all(), function($message) use ($request) {
$message->from($request->email);
$message->to('myAddress#gmail.com')
->subject($request->subject)
->replyTo($request->email);
});
For some reason From is always what's configured in my L5.1 settings but I can live with that.
Thanks #bogdan for your time and help

Resources