please, I'm new to Symfony and I'm trying to configure mailer on Symfony 2 but I'm not finding any clear doc for this.
And I'm in need of a route example to send email from an address to another just from back to test this . thank you
I tried installing swift mailer and wrote some code
<?php
namespace MailManager\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
/**
* Email Sender Manager
* @Route("/service-mail/mail")
**/
Class MailManagerController extends AbstractController {
/**
* @Route("/send")
*/
public function send(\Swift_Mailer $mailer){
$message = \Swift_Message::newInstance()
->setsubject('Mail test')
->setFrom(['mail@example.com'] => 'xxxxxx')
->setTo(['mail1@example.com'] => 'xxxxxx')
->setBcc(['mail2@example.com'] => 'vvvvv')
->setBody('Test Test');
$this->get('mailer')
->send($message);
}
}
I expect to send an email from my email address to another email address predefined, automatically when I enter the route in postman.