M
medicineman
Unregistered / Unconfirmed
GUEST, unregistred user!
我用IdSMTP做了一个简单的发邮件的东东,可是不知道为什么只能给包括自己在内的公司同事发邮件,给外面的邮箱发就会报“relaying denied to <xxxxx@msn.com>”,请教高手如何解决。或者有完备一些的实例也好,先谢过了!
以下是发邮件的简单代码:
procedure TF_STSendMail.Button2Click(Sender: TObject);
begin
IdSMTP1.AuthenticationType:=atLogin;
IdSMTP1.Username:=Edit2.Text;
IdSMTP1.Password:=Edit3.Text;
IdSMTP1.Host:='xxx.xxx.xxx.xxx';//此处为公司邮件服务器的IP
IdSMTP1.Port:=25;
try
IdSMTP1.Connect(1000);
except
StatusBar1.Panels[1].Text:='连接SMTP服务器失败!';
exit;
end;
try
With IdMessage1 do
begin
body.Clear;
body.Add(Memo1.Text);
From.Address:=Edit2.text;
Recipients.EMailAddresses:=Edit5.Text;
Subject:=Edit6.Text;
end;
IdSMTP1.Send(IdMessage1);
except
StatusBar1.Panels[1].Text:=' 发送邮件到' + Edit5.Text + '失败!';
IdSMTP1.Disconnect;
exit;
end;
StatusBar1.Panels[1].Text:='已发送到' + Edit5.Text;
IdSMTP1.Disconnect;
end;
以下是发邮件的简单代码:
procedure TF_STSendMail.Button2Click(Sender: TObject);
begin
IdSMTP1.AuthenticationType:=atLogin;
IdSMTP1.Username:=Edit2.Text;
IdSMTP1.Password:=Edit3.Text;
IdSMTP1.Host:='xxx.xxx.xxx.xxx';//此处为公司邮件服务器的IP
IdSMTP1.Port:=25;
try
IdSMTP1.Connect(1000);
except
StatusBar1.Panels[1].Text:='连接SMTP服务器失败!';
exit;
end;
try
With IdMessage1 do
begin
body.Clear;
body.Add(Memo1.Text);
From.Address:=Edit2.text;
Recipients.EMailAddresses:=Edit5.Text;
Subject:=Edit6.Text;
end;
IdSMTP1.Send(IdMessage1);
except
StatusBar1.Panels[1].Text:=' 发送邮件到' + Edit5.Text + '失败!';
IdSMTP1.Disconnect;
exit;
end;
StatusBar1.Panels[1].Text:='已发送到' + Edit5.Text;
IdSMTP1.Disconnect;
end;