开发者

smtp web.config configuration and usage

I have the following problem:

Using asp.net C# and calling several places in code to send email to the user.

However the from address in different sections of the code is different, and I have only one email address configured in web.config. This causes email sent from non-configured email addresses to go to users' junk box, how do I prevent this.

I have the following in web.config. So if from any place in the code the from address i not hello123@site.com, it will go to users' junk box.

  <smtp deliveryMethod="Network">
    <network
      host="smtp.site.com"
      userName="hello123@site.com"
      password="mypassword"
    />
  </smtp>

Here is c# code:

MailMessage message = new Ma开发者_如何学GoilMessage();
message.From = new MailAddress("forgotyourpassword@abc");
message.To.Add(new MailAddress(this.txt_Email_Pass.Text));
message.Subject = "Welcome to abc";    
message.Body ="abc";
SmtpClient client = new SmtpClient();
client.Send(message);


Unless your code is not setting the From address properly (please post the code). That has to do with your SMTP provider.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜