Last active
August 29, 2015 14:22
-
-
Save martinusso/1308e84dd735edafda09 to your computer and use it in GitHub Desktop.
Send mail using SMTP Aws-SES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure Aws_SES_SendMailUsingSMTP; | |
var | |
Username: string; | |
Password: string; | |
Host: string; | |
Port: Integer; | |
SmtpClient: TIdSMTP; | |
Msg: TIdMessage; | |
IdSSL: TIdSSLIOHandlerSocketOpenSSL; | |
begin | |
Username := 'USERNAME HERE!!!'; | |
Password := 'PASSWORD HERE!!!'; | |
Host := 'email-smtp.us-west-2.amazonaws.com'; | |
Port := 25; | |
SmtpClient := TIdSMTP.Create(nil); | |
try | |
SmtpClient.Disconnect; | |
SmtpClient.Host := Host; | |
SmtpClient.Port := Port; | |
SmtpClient.Username:= Username; | |
SmtpClient.Password:= Password; | |
IdSSL := nil; | |
try | |
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil); | |
SmtpClient.IOHandler := IdSSL; | |
SmtpClient.UseTLS := utUseImplicitTLS; | |
except | |
on E: Exception do | |
begin | |
SmtpClient.IOHandler := TIdIOHandler.MakeDefaultIOHandler(nil); | |
SmtpClient.UseTLS := utNoTLSSupport; | |
end; | |
end; | |
if Assigned(IdSSL) then | |
begin | |
IdSSL.SSLOptions.Method := sslvSSLv3; | |
IdSSL.SSLOptions.Mode := sslmClient; | |
end; | |
Msg := TIdMessage.Create(nil); | |
try | |
Msg.From.Address := '[email protected]'; | |
Msg.Recipients.EMailAddresses := '[email protected]'; | |
Msg.Subject := 'testing Amazon SES'; | |
Msg.Body.Text := 'content of testing Amazon SES'; | |
SmtpClient.Connect; | |
SmtpClient.Send(Msg); | |
SmtpClient.Disconnect; | |
finally | |
Msg.Free; | |
end; | |
finally | |
SmtpClient.Free; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment