I want to write a class for send mail with sendgrid on Laravel 5.1
I want to know better way to implement mail send function in Laravel.
I thought to create a serviceProvider. Is there any other suggestion for make better ?
Thanks in advance.
You can just use the Sendgrid SMTP server, as shown in their Laravel integration documentation.
Just edit your .env file like that:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_USERNAME=your Sendgrid username
MAIL_PASSWORD=your Sendgrid password
Then you can use Mail::send() just like you normally would.
Related
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
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.
So I currently have setup my laravel project in C-panel, and have updated the .env file to have the appropriate email address. When I, for instance, use the make:auth reset password feature it responds with the appropriate "We have e-mailed your password reset link!", but there is no mail sent.
I am not sure how to test this to find the hole in the problem. When I used mailtrap I was able to send and receive emails no problem, but there is some issue with the webmail in c-panel not processing and sending out an email from Laravel 5.4
Help please
change your .env file. set MAIL_DRIVER=mail it will start working. make sure you set from in mail.php
`
I want send the mails using the Laravel Mail Class with blade templates and without using the third party service provider like mailgun etc...
you just need to set your .env file with the details of your SMTP server login credentials:
MAIL_DRIVER=smtp
MAIL_HOST=<your smtp server>
MAIL_PORT=<25/465/587>
MAIL_USERNAME=<smtp user>
MAIL_PASSWORD=<smtp pass>
MAIL_ENCRYPTION=<tls/ssl>
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