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 = MagentoFrameworkAppBootstrap::createObjectManagerFactory(BP, []);
$objectManager = $objectManagerFactory->create([]);
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('global');
$email = new Zend_Mail();
$email->setSubject("Feedback email");
$email->setBodyText('test mail');
$email->setFrom('b2c@afsupply.com', 'AFSupply');
$email->addTo('medfosys.developer57@gmail.com', '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.