sendMail static method
Implementation
static Future<String?> sendMail(
{required String body,
required String title,
required String email}) async {
String username = 'dev.3tit@gmail.com';
String password = 'axgk hevk wcvj qnye';
final smtpServer = gmail(username, password);
final message = Message()
..from = Address(username, 'Dev 3T')
..recipients.add(email)
..subject = title
..text = body;
try {
await send(message, smtpServer);
return null;
} on MailerException catch (e) {
print('Message not sent. ${e.message}');
for (var p in e.problems) {
print('Problem: ${p.code}: ${p.msg}');
}
return e.message;
}
}