I need a component to send emails in a Firemonkey application that works on Windows, iOS and macOS and with all types of servers..
Currently I need to create settings and code to select the correct component as per the user's email server.
If the server is SMTP, I use Indy. If the server is GMail I use the TMS FNC Cloud Pack. If the user wants to send emails using the device's email program I use FirePower, etc.
This new component should have several settings that would be passed by the developer, for example:
Server Type: SMTP, GMail, Outlook, local message program, etc.
Connection Settings: SSL, StartTSL, Port, etc.
Server address: when necessary
Sent email: email that is sending the message
Login name: Username for connecting to the server (when necessary).
Password: User password for connecting to the server (when necessary).
Once configured, messages would be sent by calling a function like:
..Send_Mail( emails, ccemails, bccemails, subject, message, attachfile);
This function would return true if the email was sent successfully.
Example:
if XX.Send_Mail( ['samuel@gmail.com', 'john@gmail.com'], //recipient - optional
['tms@tms.com.br'], //cc email - optional
[], //bcc email - optional
'Test Message', //Subject
'This is a <B> Test Message </B> of the component', //HTML Message
'C:\Download\Filename.pdf') //Attached file - optional
Then
ShowMessage ("ok")
Else
ShowMessage("Error code: "+XX.CodeError.ToString);