Want to send mail through Swift Mailer in symfony
Posted By : Rahul kothari | 31-Jan-2022
We will provide you with information to use Swift mailer to send mail in symfony.
Add swift mailer configuration in config.yml.
# Swiftmailer Configuration swiftmailer: transport: '%mailer_transport%' host: '%mailer_host%' username: '%mailer_user%' password: '%mailer_password%' encryption: 'tls' |
Create a function like this in which create a interface and setSubject, setfrom, setTo and setBody function and use $this->get('mailer')->send($message) to send a email to the given email-id.
public function quitarDistincionAction(Request $request) $em = $this->getDoctrine()->getManager(); $postulacion = $em->getRepository('AssertsoftMunicipalidadBundle:Postulacion')->findOneBy(array('id' => $request->get('postulacion_id'))); $postulacion->setDistincion(false); return $this->render('@AssertsoftMunicipalidad/municipalidad/distincion_otorgada.html.twig', array( 'postulacion' => $postulacion, 'cantidad_autoevaluaciones' => $cantidad_autoevaluaciones, |
you can also provide the number of header field to describe the content. For Example in this you can Tell the repliers that this mail is automated please do not reply to this mail.
$email = (new Email())
->getHeaders()
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply')
;
You can provide the credentials and smtp details for swift mailer in your config file.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Rahul kothari
Rahul is a highly experienced Backend developer, with broad range of skills and expertise in various technologies. He has practical experience working with PHP, Javascript, HTML, CSS, Laravel, Drupal, Symfony, Wordpress, REST API, GRAPH QL, and various databases. He is also knowledgeable in AWS, Jenkins, GIT, and agile methodology tools like JIRA, Confluence, and Trello. In his various projects, such as Babyflix, Script TV, Dollibar, and Sernatur, he has contributed to both front-end and back-end development, including REST API development, module development, and working with AWS services. Rahul is dedicated to delivering high-quality work and ensuring client satisfaction.