Using renderStoredEmailTemplate(templateId, whoId, whatId) method of Messaging Class, we can send email to non-contacts using apex. Here is an example to send email to Opportunity owner.
Sample code:
//Send email to opportunity owner
Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(emailTemplateId, ownerId, opportunityId);
mail.setTargetObjectId(ownerId);
mail.setSubject(mail.getSubject());
mail.sethtmlBody(mail.gethtmlBody());
mail.saveAsActivity = false;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
Set<String> accountNameMatches = new Set<String> { 'A%', 'B%', '%C%', '%D' };
List<Account> accList = [SELECT Id FROM Account WHERE Name LIKE :accountNameMatches];
system.debug('accList-' + accList);