Home > Back-end >  Use delphi10 idsmtp mailing problem with idmessage connection QQ mailbox
Use delphi10 idsmtp mailing problem with idmessage connection QQ mailbox

Time:09-20

Hello, everyone, I am currently using idsmtp and idmessage don't send email
QQ also launched a POP3/SMTP service
The QQ password box requirements input "authorization code" validate
The core code is as follows, please help me find the reason, or give me some to connect QQ mailbox to use the core code, thank you,


///Port1 Host1 SMTP server port number/ssl1 SSL/with username1 is mail account/password Password1 mailbox
The function email_connect (Host1: string; Port1: integer; Ssl1: string; With username1 is: string; Password1: string) : Boolean;
//email from_adrss send mail account/to_adrss email account/path/msgMemo file_name attachment E-mail mail subjects/str_zt
The function SendEMail (from_adrss: string; To_adrss: string; File_name: string; MsgMemo: Tmemo; Str_zt: string) : Boolean;
Procedure email_disconnect;

Implementation
Var
Idsmtp1: TIdSMTP;
IdAntiFreeze1: TIdAntiFreeze;
Idmessage1: TIdMessage;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;

///Port1 Host1 SMTP server port number/ssl1 SSL/with username1 is mail account/password Password1 mailbox
The function email_connect (Host1: string; Port1: integer; Ssl1: string; With username1 is: string; Password1: string) : Boolean;
The begin
Try
IdAntiFreeze1:=TIdAntiFreeze. Create (nil);
Idsmtp1:=TidSMTP. Create (nil);
Idmessage1:=TIdMessage. Create (nil);
IdSSLIOHandlerSocketOpenSSL1:=TIdSSLIOHandlerSocketOpenSSL. Create (nil);

Idsmtp1. Host:=Host1;
Idsmtp1. Port:=Port1;
Idsmtp1. Username:=with username1 is;
Idsmtp1. Password: Password1=;

If ssl1='Y' then
The begin
IdSSLIOHandlerSocketOpenSSL1. SSLOptions. Method:=sslvSSLv3;
IdSMTP1. IOHandler:=IdSSLIOHandlerSocketOpenSSL1;
end;

Idsmtp1. Connect;

Result:=True;
Except,
Result:=False;
end;
end;

Procedure email_disconnect;
The begin
Try
Idsmtp1. Disconnect;
IdAntiFreeze1. Free;
Idsmtp1. Free;
Idmessage1. Free;
IdSSLIOHandlerSocketOpenSSL1. Free;
Except,
end;
end;

//email from_adrss send mail account/to_adrss email account/path/msgMemo file_name attachment E-mail mail subjects/str_zt
The function SendEMail (from_adrss: string; To_adrss: string; File_name: string; MsgMemo: Tmemo; Str_zt: string) : Boolean;
The begin
Try
//clear the attachment
Idmessage1. MessageParts. The Clear;
//add attachments
TIdAttachmentFile. Create (idmessage1 MessageParts, file_name);

Idmessage1. Body. The Clear;
Idmessage1. Subject:=str_zt;
Idmessage1. CharSet:='gb2312';
Idmessage1. Body. Assign (msgMemo. Lines);
Idmessage1. The From. Address:=from_adrss;
Idmessage1. Recipients. EMailAddresses:=to_adrss;
Idsmtp1. Authenticate;
Idsmtp1. Send (idmessage1);

Result:=True;
Except,
Result:=False;
end;
end;

Execute the following code:
Try
If not sp_mail. Email_connect (' smtp.qq.com ', 465, 'Y', '123456789 @qq.com', 'nhcnuddxofibbjjb) then
The begin
ShowMessage (' mail server connection failure! ');
exit;
end;


If not SendEMail (' 123456789 @qq.com ', '55555 @qq.com, c.s. ql' d: \ ', memo1, 'theme') then
The begin
ShowMessage (' send failed! ');
exit;
end;



ShowMessage (' sent successfully! ');
The finally
Sp_mail. Email_disconnect;
end;

CodePudding user response:

Top your ah

CodePudding user response:

The function email_connect (... )
.
If not sp_mail. Email_connect (... )

Before and after the wrong

CodePudding user response:

If ssl1='Y' then//don't

IdSSLIOHandlerSocketOpenSSL1. SSLOptions. Method:=sslvSSLv1;//not sslvSSLv3

Idsmtp1. UseTLS:=utUseImplicitTLS;//to set up the

Idmessage1. CharSet:='gb2312';//this can't solve the problem of gibberish

I made a success, environment Delphi 2010 + win 7
Have a friend need to please contact QQ: 443404123

CodePudding user response:

Forgot that you need to use the two supporting DLL: libeay32. DLL, ssleay32. DLL
  • Related