Laravel 5.5 - Sending Email / Env File

Asked

Viewed 794 times

1

I am migrating a site I have to Laravel 5 and I came across a problem.

To email in Laravel I need to manually fill in the user and host port data in the file . env

As in my site I have an interface for the user to interact, I end up receiving this encrypted data from the database, for this fact, it becomes impossible to fill in the data MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD manually in the file . ENV, so I ask:

It is possible to pass this to the ENV file or access a function in which I can directly pass this data and be able to fire the email?

  • If that data is in the database, just create a Model to capture and use in the sending function.

  • But what is the sending function? The sending routine works.. the data is in a model, I need to take the data just this, how will I pass the data to the send non-env file? That’s what I can’t do !

  • If possible edit your question and ask how you are sending this data.

  • problem solved.. posted a reply..

1 answer

2


I solved my problem this way:

Lavavel has a form of access in which we can set the properties at runtime directly using config.

As I wanted to fill the email settings, I needed to access the properties responsible for the email that is on Config Mail.php.

Through the above item I was able to identify the name of each property to set the values in this way:

    config(['mail.host' => 'smtp.meusite.com.br']);
    config(['mail.port' => '587']);
    config(['mail.username' => '[email protected]']);
    config(['mail.password' => 'senha']);

Below is the documentation link for those who need it!

https://laravel.com/docs/5.3/configuration#accessing-Configuration-values

Browser other questions tagged

You are not signed in. Login or sign up in order to post.