我正尝试使用此方法通过我的程序发送电子邮件:
MailMessage email = new MailMessage("IT_REQUEST@creandsel.com.au", "ben.hall@creandsel.com.au");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "hp132.hostpapa.com";
email.Subject = "New IT Request";
email.Body = Model.Description;
client.Send(email); // Error catches here
但是我收到错误消息:
邮箱不可用。服务器响应为:拒绝访问 - 无效的HELO名称(请参阅RFC2821 4.1.1.1)
我尝试过替代主机(creandsel.com.au),效果相同。我相信这可能是因为我将其从内部网络发送给第三方电子邮件提供商。
此外,不确定这是否重要,但发件人(IT_REQUEST@creandsel.com.au)不存在。
答案 0 :(得分:0)
首先确保您的环境的SMTP为enabled。如果已启用,则需要传递SMTP凭据(用户名/密码对),因为未使用SMTP服务器成功进行身份验证。
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
// explicitly declare that you will be providing the credentials:
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("username", "password");
client.Host = "hp132.hostpapa.com";
email.Subject = "New IT Request";
email.Body = Model.Description;