procedure TfmWarenKorb.SendEmail(const Recipients: string; const CCList: string; const Subject: string; const Body: string; Att: Boolean; Filename:String);
var
SMTP: TIdSMTP;
Email: TIdMessage;
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
Attachment: TIdAttachment;
I: Integer;
begin
SMTP := TIdSMTP.Create(nil);
Email := TIdMessage.Create(nil);
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
SMTP.IOHandler:= SSLHandler;
try
SSLHandler.MaxLineAction := maException;
SSLHandler.SSLOptions.Method := sslvTLSv1;
SSLHandler.SSLOptions.Mode := sslmUnassigned;
SSLHandler.SSLOptions.VerifyMode := [];
SSLHandler.SSLOptions.VerifyDepth := 0;
SMTP.IOHandler := SSLHandler;
SMTP.Host := '
smtp.gmail.com';
SMTP.Port := 587;
SMTP.Username := 'XXXXX'; // Username
SMTP.Password := 'XXXXXX'; //Passwort
SMTP.UseTLS := utUseExplicitTLS;
if Att = true then
Attachment := TIdAttachmentFile.Create(Email.MessageParts, Filename);
Email.From.Address := 'MAILADRESSE'; //Angezeigte Email Adresse
Email.Recipients.EmailAddresses := Recipients;
{for I := 0 to ccList.Count-1 do
begin
EMail.CCList.Add.Address := CCList.Strings[i]; //StringReplace(CCList,sLineBreak,',',[rfReplaceAll]);
end; }
//EMail.CCList.Add.Address := CCList;
Email.Subject := Subject;
Email.Body.Text := Body;
SMTP.Connect;
SMTP.Send(Email);
SMTP.Disconnect;
finally
if Att = true then Attachment.Free;
SMTP.Free;
Email.Free;
SSLHandler.Free;
end;
end;