- Peace Media
- Member | 1
I'm hoping for a more complete example of how to use SmtpMailer with the configuration (server address, username, password, etc) in a Neon file. The documentation implies that I don't have to load it manually and can instead get it via injection somehow:
“Overview of configuration options for the Nette Mail. If you are not using the whole framework, but only this library, read how to load the configuration.”
Well, I'm using the whole framework, but I admit I'm still a bit confused by how the injection/autoloading stuff works. My first guess was that I could get SmtpMailer injected into the class I'm doing my mailing from and it would be autoconfigured when I get it, but that doesn't seem to be the case, or at least I can't figure out how to set things up that way. If someone could throw together an example of the “right” way to get a configured SmtpMailer instance injected into my code, I'd appreciate it.
Here's my services.neon at least at the point I decided to give up and post on this forum. SVMailer is the class I'm trying to send mail from. I want it to be injected into Presenters which will need to send mail so I defined it as a service.
search: - in: %appDir% classes: - *Factory services: - App\Router\RouterFactory::createRouter SVLogger: App\Util\SVLogger(@database.main.connection) - App\Util\SVMailer(@SVLogger, Nette\Mail\SmtpMailer())
And the mail section of my local.neon is basically in line from what's on the documentation page:
mail: smtp: true host: smtp.[domain] port: 587 encryption: tls username: [username] password: [password]