We have one visualforce page which is working fine previously for sending emails but now it is not working. All other functions from that visualforce page are working fine But send mail functionality is not working which worked previously. For the admin user, it is working fine if we preview the visualforce page from the developer console. It is not working only for guest users. Also checked the profile and site setting but did not find anything.
For sending mail code is given below:-
Messaging.singleEmailMessage mail = new Messaging.singleEmailMessage(); List<String> sendTo = new List<String>(); sendTo.add(con.Email); mail.setToAddresses(sendTo); mail.setReplyTo('[email protected]'); mail.setSenderDisplayName('twopir consulting'); mail.setSaveAsActivity(false); mail.setSubject('Token for Employee Portal Login'); String body = '<html><body>Dear ' + contactList.Name + ',<br><br>Use Token : ' +systemToken+' to log into Employee Portal</body></html>'; mail.setHtmlBody(body); mails.add(mail); Messaging.sendEmail(mails);
Can you please help us for solving the issue?