1./ Currently the "From" contains my email address, but my name would be better there. Is it possible?
Yes, it is possible:
IdMessage.From.Name := 'My Name';
IdMessage.From.Address := 'me@domain.com';
3./ The sending function works great with TLS and port 587 (Gmail). What should I change in the settings to get SSL and port 465 to work? I mean, there are many options in TIdSSLIOHandlerSocketOpenSSL for SSLOptions, bit confusing.
Implicit vs Explicit is a completely different thing than using SSL v2.0/3.0 vs TLS 1.0/1.1/1.2.
Port 465 uses Implicit SSL. That means the client must initiate an SSL/TLS handshake (using SSL 2.0/3.0 or TLS 1.0/1.1/1.2 as needed) immediately upon establishing the socket connection, before then performing any STMP related I/O. Reading the server's greeting, sending commands, reading responses, they will ALL be encrypted. This scenario is handled by setting the TIdSMTP.Port to 465 and the TIdSMTP.UseTLS to utUseImplicitTLS, and configuring the SSLIOHandler as desired.
Port 587 uses Explicit TLS. That means the client must NOT initiate an SSL/TLS handshake until it has first issued an unencrypted STARTTLS command and received a success reply back. Prior to receiving a STARTTLS success response, everything will NOT be encrypted. This scenario is handled by setting the TIdSMTP.Port to 587 and the TIdSMTP.UseTLS to utUseExplicitTLS, and configuring the SSLIOHandler as desired.
4./ Currently I'm using this method for attachment:
Attachment := TIdAttachmentFile.Create(MailMessage.MessageParts, attFile);
It only send 1 attached file. How can I send more than 1 attached files?
Simply create additional TIdAttachmentFile objects as needed, one per file. The TIdMessage.MessageParts property is a collection, it can hold multiple TIdMessageParts-derived objects.
4. is solved with a loop:
for i := 0 to slAttachedFiles.Count - 1 do
begin
if FileExists(slAttachedFiles[i]) then TIdAttachmentFile.Create(MailMessage.MessageParts, slAttachedFiles[i]);
end;
Yes, that would be the way to go.