我写了一断用TidSMTP发邮件的代码,能够连接SMTP服务器,但是在调用 Fsend.Send(Femail);的
时候会报错,TOM的邮件服务器报的是我没被授权使用<From:[email protected]>
我们公司的邮件服务器报的错误是“Need RCPT first”
我的代码是:
begin
try
try
FSend.Username:='*****';
FSend.Host :='*****';
FSend.Port :=25; FSend.Password :='*****';
Femail.From.Text :=FSend.Username ;
Femail.ReceiptRecipient.Address := FSend.Username;
Femail.Subject :='邮件测试';
Femail.Body.Text :='测试测试测试'; Fsend.Connect;
Fsend.Send(Femail);
application.MessageBox('发送成功','成功',MB_ok);
Except
Fsend.DisconnectSocket ;
Fsend.Disconnect ;
application.MessageBox('连接SMTP服务器出现错误','错误',MB_ICONERROR);
exit;
end;
finally
Fsend.DisconnectSocket ;
Fsend.Disconnect ;
end;
end;
时候会报错,TOM的邮件服务器报的是我没被授权使用<From:[email protected]>
我们公司的邮件服务器报的错误是“Need RCPT first”
我的代码是:
begin
try
try
FSend.Username:='*****';
FSend.Host :='*****';
FSend.Port :=25; FSend.Password :='*****';
Femail.From.Text :=FSend.Username ;
Femail.ReceiptRecipient.Address := FSend.Username;
Femail.Subject :='邮件测试';
Femail.Body.Text :='测试测试测试'; Fsend.Connect;
Fsend.Send(Femail);
application.MessageBox('发送成功','成功',MB_ok);
Except
Fsend.DisconnectSocket ;
Fsend.Disconnect ;
application.MessageBox('连接SMTP服务器出现错误','错误',MB_ICONERROR);
exit;
end;
finally
Fsend.DisconnectSocket ;
Fsend.Disconnect ;
end;
end;
FSend.Password :='*****';
FSend.Host :='*****';
FSend.Port :=25;
FSend.AuthenticationType := atLogin; Femail.From.Text := '你的邮件地址';
Femail.ReceiptRecipient.Address := '接收邮件地址';
Femail.Subject :='邮件测试';
Femail.Body.Text :='测试测试测试'; Fsend.Connect;
Fsend.Send(Femail);