I am using SMTP on my website and all the mails are working fine. I am receiving all the emails. Now I am developing a custom script on magento root to send mails but it is not working. This is the link that I am using to create the script. Magento 2: Sending Email Programmatically
This is the solution from the above link that I am using.
The code that I have created on magento root
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
require __DIR__ . '/app/bootstrap.php';
$objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []);
$objectManager = $objectManagerFactory->create([]);
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('global');
$email = new \Zend_Mail();
$email->setSubject("Feedback email");
$email->setBodyText('test mail');
$email->setFrom('[email protected]', 'AFSupply');
$email->addTo('[email protected]', 'Rajeev');
$email->send();
I do not see any error message but I never receive the mails. Plz let me know what I am doing wrong as according to me this should work as the answer in the link has many upvotes. Plz suggest as I am stuck in this.
Magento\Framework\Mail\Template\TransportBuilder
for sending emails. please check meetanshi.com/blog/… bsscommerce.com/confluence/how-to-send-email-in-magento2