我知道要从SMTP服务器发送电子邮件,需要服务器地址,密码和用户名/默认凭据。但是,SMTP是否也有密码来访问服务器本身?还有用户名吗?
答案 0 :(得分:1)
这是对我有用的补充:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("receiveremailaddress@xxx.com");
message.Subject = "This is the Subject line";
message.From = new MailAddress("youremailaddress@xxx.it", "Name to Display");
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Credentials = new NetworkCredential("youremailaddress@xxx.it", "yourpassword");
smtp.Send(message);
答案 1 :(得分:0)
你需要的只是
您不需要密码到服务器本身"或类似的东西。
根据服务器配置,您发送的电子邮件"来自"可能需要也可能不需要是该服务器上的有效电子邮件地址。
编辑:基本的C#实现
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("luckyperson@online.microsoft.com");
message.Subject = "This is the Subject line";
message.From = new System.Net.Mail.MailAddress("yourmailuser@yourhost.com",25);
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
// if you need user/pass login
client.Credentials = new NetworkCredential("username","password");
smtp.Send(message);
答案 2 :(得分:0)
“但是,SMTP是否也有密码来访问服务器本身?还有用户名吗?”
不,您可能需要的唯一密码是有资质的电子邮件帐户。