STARTTLS error while sending email using Indy in Delphi XE -


i'm trying send email application using following code:

  var   mailmessage : tidmessage;   smtp        : tidsmtp    .    .    .  //setup smtp  smtp.host := 'smtp.gmail.com';  smtp.port := 25;  //setup mail message  mailmessage.from.address := 'fromme@gmail.com';  mailmessage.recipients.emailaddresses := 'tosomeone@hotmail.com';  mailmessage.subject := 'test';  mailmessage.body.text := 'hello, test';   smtp.connect;  smtp.send(mailmessage); 

when run it, generates following error

**error: must issue starttls command first. i29sm34080394wbp.22** 

how can solve this?

by putting answers can following code. don't forget nathanial woolls mentioned here put libeay32.dll , ssleay32.dll libraries instance here project folder or path following places.

uses   idmessage, idsmtp, idsslopenssl, idglobal, idexplicittlsclientserverbase;  procedure sendemail(const recipients: string; const subject: string; const body: string); var   smtp: tidsmtp;   email: tidmessage;   sslhandler: tidssliohandlersocketopenssl; begin   smtp := tidsmtp.create(nil);   email := tidmessage.create(nil);   sslhandler := tidssliohandlersocketopenssl.create(nil);    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 := 'yourusername@gmail.com';     smtp.password := 'yourpassword';     smtp.usetls := utuseexplicittls;      email.from.address := 'yourusername@gmail.com';     email.recipients.emailaddresses := recipients;     email.subject := subject;     email.body.text := body;      smtp.connect;     smtp.send(email);     smtp.disconnect;        smtp.free;     email.free;     sslhandler.free;   end; end;  procedure tform1.button1click(sender: tobject); begin   sendemail('recipient@whatever.com', 'subject', 'body'); end; 

hope help


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -