IDSmtp无法发送邮件
使用OUTLOOK可以收信件发信件,但是用IDSMTP无法发送信件,好象对方收不到
这边显示成功
procedure TForm1.Button1Click(Sender: TObject);
var
IdMessage: TIdMessage;
IdSMTP: TIdSMTP;
Message: TStrings;
i: Integer;
Fichiers: Array Of String;
begin
IdMessage := TIdMessage.Create(nil);
IdMessage.From.Address := 'cs@csu-pm.com;
IdMessage.ReplyTo.Add.Address := 'cs@csu-pm.com';
IdMessage.Recipients.Add.Address := 'goto21cn@hotmail.com' ;
IdMessage.Subject := 'Sujet du message';
IdMessage.ContentType := 'multipart/alternative';
Message := Memo1.Lines;
With TIdText.Create(IdMessage.MessageParts, Message) Do
Begin
ContentType := 'text/plain';
Body.Insert(0, 'Ce message est un message HTML... Configurez votre client de courrier électronique' +
'pour le visionner de manière appropriée');
end;
with TIdText.Create(IdMessage.MessageParts, Message) do
ContentType := 'text/html';
for i := Low(Fichiers) to High(Fichiers) do
TIdAttachment.Create(IdMessage.MessageParts, Fichiers[i]);
IdSMTP := TIdSMTP.Create(nil) ; //Création dynamique du composant
IdSMTP.Port := 25; //Le port SMTP standard…
IdSMTP.Host := 'mail.csu-pm.com'; //Le serveur auquel se connecter
IdSMTP.AuthenticationType := atLogin;
IdSMTP.Username := 'cs@csu-pm.com';
IdSMTP.Password := 'tomato*****';
Try
Try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
except
on e: exception do MessageDlg(e.Message, mtError, [mbOK], 0);
end;
finally
IdSMTP.Disconnect;
IdSMTP.Free;
IdMessage.Free;
end;
end;