How to send email by TIdSMTP VCL ? | ||
| ||
| uses IdSMTP, IdMessage;; procedure KMAIL( sTo, title, body:string); var IdMsg : TIdMessage; begin IdMsg := TIdMessage.Create(nil); try with TIdSMTP.Create(nil) do try UserName := SMTPFrm.m_username.Text; Password := SMTPFrm.m_password.Text; Host := SMTPFrm.m_host.Text; IdMsg.Body.Add(body); IdMsg.Recipients.emailAddresses := sTo; IdMsg.Subject := title; IdMsg.From.Address := SMTPFRm.m_email.Text; IdMsg.From.Name := SMTPFRm.m_realname.Text; Connect; Send(IdMsg); Disconnect; finally Free; end; finally IdMsg.free; end; end; procedure TMainFrm.Button1Click(Sender: TObject); begin KMAIL( 'foo@foo.com', 'Test mail from kurapa', 'Man, this is test mail from kurapa!!'); end; As you can see above, you need Host, User ID, Password for sending email. In addition, you can define SMTP port as well. | ||
| | ||
| |