一个用TidSMTP控件实现发送邮件遇到的问题,请各位帮忙
我在用TidSMTP控件实现发送邮件时,用我的163邮箱在给我的gmail邮箱发邮件能够很快的发送成功,gmail也能够收到。但是当我用我的163邮箱给我的126邮箱发邮件时,虽然说能够在我的客户端能够发送出去,系统也不抱错,但是我的126就是收不到邮件,这是怎么回事呀,向各位请教。我写的代码如下。
//首先和SMTP服务器建立连接,发信的功能在OnConnect
void __fastcall TFormNewMail::Button2Click(TObject *Sender)
{ bool au;
//首先和SMTP服务器建立连接,发信的功能在OnConnect
IdSMTP1->Host = FormConfig->EditSMTP->Text;
IdSMTP1->AuthenticationType = atLogin;
IdSMTP1->UserId = FormConfig->EditUser->Text;
IdSMTP1->Password = FormConfig->MaskEditPw->Text;
IdMessage1->ContentType = "text/html";
IdMessage1->From->Text = FormConfig->EditUser->Text;
IdMessage1->ReplyTo->EMailAddresses = FormConfig->EditUser->Text ;
IdMessage1->From->Name = FormConfig->EditName->Text;
IdMessage1->Recipients->EMailAddresses = EditToAddress->Text;
IdMessage1->Subject = EditSubject->Text;
IdMessage1->Body->Assign(MemoNewMail->Lines);
IdMessage1->ReceiptRecipient->Text = FormConfig->EditUser->Text;
IdMessage1->MessageParts->Clear();
IdMessage1->MessageParts->Add();
new TIdAttachment(IdMessage1->MessageParts,ComboBoxAttach->Text);
if(!IdSMTP1->Connected())
{
IdSMTP1->AuthenticationType = atLogin;
IdSMTP1->Connect();
Application->MessageBox("连接服务器成功", "Look", MB_OK);
if( IdSMTP1->Authenticate()){
ShowMessage("授权成功,等待发送") ;
try
{IdSMTP1->Send(IdMessage1);
ShowMessage("邮件发送成功") ;
}
catch(Exception &E)
{ ShowMessage("发送邮件时出现异常");} ;
}else{
ShowMessage("服务器连接不成功");
}
}
}