I have a visualforce page which does some calculations and sends email to the concerned people.
The problem I am facing is - the email is sent from the apex class perfectly without any errors or limits exceeded but it is not received at the users end.
I checked the spams for the email accounts and the email was not there.
I also do not see any errors happening at apex side. To test it further, I removed the email functionality from the logic and just did a dummy email test run, but it did not work either
private static void testEmail() {
try {
List<String> emailAddressList = new List<String>();
emailAddressList.add('someemail@email.com'); -- (I put my personal email here)
List<Messaging.SingleEmailMessage> mailsList = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(emailAddressList);
mail.setSubject('subject for this email');
mail.setHtmlBody('blab blah blah.....');
mailsList.add(mail);
List<Messaging.SendEmailResult> emailResultList = Messaging.sendEmail(mailsList);
System.debug('-------------------------------------- Email sent status : ' + emailResultList[0].isSuccess());
} catch(Exception e) {
System.debug('---------------- Error occurred in testEmail() : ' + e.getStackTraceString());
}
}
When this method is called, the email sent status is true.
This is a simple email and it did not work. I don't understand what is going wrong.