Is it possible to send email using configuration from another shared hosting? - laravel

My Laravel Apps cannot send email using another shared hosting configuration.
I'm developing laravel app (Laravel 5.7), one of my apps function is to send email after register new account. I have deployed my apps to my VPS and I have account on a shared hosting. I used my shared hosting configuration for sending email and I have added the config to my .env file, like
MAIL_DRIVER=smtp
MAIL_HOST=mail.embara.id
MAIL_PORT=465
MAIL_USERNAME="username"
MAIL_PASSWORD="password"
MAIL_FROM_ADDRESS="FROM"
MAIL_FROM_NAME="FROM NAME"
MAIL_ENCRYPTION=null
but nothing happen, only failed (I am using queue, and i have tested using mailtrap.io, everything works fine)
Anyone knows what is wrong with my config?
Thanks

Think you need ssl, try this:
MAIL_DRIVER=smtp
MAIL_HOST=mail.embara.id
MAIL_PORT=465
MAIL_USERNAME=noreply#embara.id # <-- full email address
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=ssl # <-- This

Related

Failed to send message from Laravel controller

I tried to send an email from a Laravel controller, but it's showing this error. I'm not using a two step verified Gmail account. Most tutorials use the "enable less secure app" settings, but I can't enable that option in my account.
this is my env file
MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=******
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=********
MAIL_FROM_NAME="${APP_NAME}"
Please use your google app password in MAIL_PASSWORD

having issues on sending email in laravel 5.8

I am having issues on sending email via notification. I tried accessing the mailbox using the credentials I put in .env, the credential is good I am able to access the inbox but if I run the command sending email is failed.
on my .env
MAIL_DRIVER=smtp
MAIL_HOST=myhost
MAIL_PORT=465
MAIL_USERNAME=this#isworkingemail.com
MAIL_PASSWORD=pWdisWorking
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=this#isworkingemail.com
MAIL_FROM_NAME='AFTSCredit'
my function via
public function via($notifiable)
{
return [TwilioChannel::class,'database','mail'];
// return [TwilioChannel::class,'database'];
}
any idea? plase help thank you in advance!
Your error says Authentication error. This is nothing to do with Laravel/PHP mailer.
Try one of these below:
Clear cache
Check if you have modified config file. Make sure your .env variables are being pointed in your config file
Check if your server allows outbound emails
Check if you have right credentials such as host name, username, password
If you need extra authentication to allow using smtp services like google. You will need to activate to allow to use less secure app.
Finally, but not the least
If your mail server password contains a # then you should quote the environment string since everything after # will be taken as comment (starting in Laravel 5.8)
put the port and host as follows
MAIL_PORT = 587
MAIL_HOST= smtp.gmail.com
and also in your gmail . Disable two authentication and enabled unsecured apps
and then it would be okkay

How to configure postfix and Laravel on same server

I am developping a complex website but when I try to deploy it I got an error whenever the website needs to send an email (for the email validation system, built-in with Laravel). The error I got is:
[ErrorException (E_NOTICE)] Undefined offset: 3
The exception seems to be thrown from /vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php.
The only changes I made to config/mail.php is to allow self-signed certificates for ssl. My .env file contains these lines:
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=myusername //match in real file
MAIL_PASSWORD=mypassword //match in real file
MAIL_FROM_ADDRESS=from#mydomain.stackoverflow
MAIL_FROM_NAME=MyAppName
MAIL_ENCRYPTION=tls
My mail server is on the same server (as you could guess with MAIL_HOST=localhost) and is running postfix with Dovecot. I'm also using a webmail app (roundcube) to use my mail server and it works fine (except for OpenDKIM which doesn't sign outcoming mails).
Do you have any idea where my problem can come from?
EDIT: It works with Mailtrap.io so the problems should come fromp the configuration but I don't know if it comes from my Postfix config or from my Laravel config
EDIT2: I still don't understand why but removing credentials works fine. It works with credentials but only if I remove the MAIL_ENCRYPTION option (setting it to null). So here is the working config I have:
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS=from#mydomain.stackoverflow
MAIL_FROM_NAME=MyAppName
MAIL_ENCRYPTION=tls

Laravel mail on shared hosting

I've a form contact on my website and I want the form to be sent via email when submitted.
I've tried it in xampp and it's working fine.
On shared hosting, it does not work.
I'm using my own custom domain smtp.
Someone can explain me why it's not working ?
Your shared hosting probably blocks outgoing SMTP connections. Many hosting providers do that to prevent spam. You can try using a HTTP/WEB API instead of SMTP to send email.
Some email APIs like Flute Mail allow you to set up an HTTP API connection which can immediately forward the request through your "custom domain smtp" server. So you can keep using your custom domain email server, but get an API for it.
Otherwise you'll have to set up a Web API yourself with an open source tool like Postal.
In your laravel .env file if add following parameters mentioned below and create a e-mail on your shared hosting and add username, password and host of your hosting.
MAIL_DRIVER=smtp
MAIL_HOST=shared_host_name
MAIL_PORT=587
MAIL_USERNAME=mail#sharedhost.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I suppose then it would work fine.

Email Configration Laravel

Hello guys I'm new to laravel. I'm trying to send a email but I can't understand how to configure it. I was looking at their email configuration and they were setting it up for mailgun etc. I don't want to set it up for any service. and if I have to is there any free service that can help me. Can somebody please explain to me how can I do that and I'm using Laravel 5.2
You can use any free service, like Gmail or Sendgrid, for example.
Just fill settings in .env file to make it work:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=yourEmail
MAIL_PASSWORD=yourPassword
MAIL_ENCRYPTION=tls

Resources