0
好傢伙我有一個問題在我的ASP.Net項目被折磨着我像...永遠!所以我的問題是,我可以在新用戶註冊後發送電子郵件,但它使用默認憑據,即使我將其設置爲false。我不希望新用戶看到我的實際Gmail或Outlook電子郵件,我想將其帶到更專業的級別,如「[email protected]」或類似的東西。我不打算註冊一些web服務,並付出了很多錢,只是爲了創建一個自動響應的電子郵件,我永遠不會檢查你知道...這是我的Web.config SMTP代碼:ASP.Net C#應用程序不無默認憑據發送電子郵件
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="false" host="smtp.gmail.com" port="587" userName="My actual Gmail" password="My Password" enableSsl="true" />
</smtp>
</mailSettings>
這裏是我在Registration.aspx.cs代碼:
MailMessage activationMail = new MailMessage();
string useractivation = "http://localhost:53631/Account/Activation.aspx?username=" + username.Text;
activationMail.From = new MailAddress("[email protected]", "My E-Mail Displaying Name");
activationMail.To.Add(mail1.Text);
StreamReader sRead = new StreamReader(Server.MapPath("~/Mails/ActivationMail.html"));
string readFile = sRead.ReadToEnd();
string Strcontent = "";
Strcontent = readFile;
Strcontent = Strcontent.Replace("[Name]", realname.Text);
Strcontent = Strcontent.Replace("[Username]", username.Text);
Strcontent = Strcontent.Replace("[Password]", pass1.Text);
Strcontent = Strcontent.Replace("[useractivation]", useractivation);
Strcontent = Strcontent.Replace("[Site]", "http://localhost:53631");
Strcontent = Strcontent.Replace("[Facebook]", "facebook");
activationMail.Subject = "Your Registration to ASP.Net website or something...";
activationMail.Body = Strcontent.ToString();
activationMail.IsBodyHtml = true;
activationMail.BodyEncoding = UTF8Encoding.UTF8;
activationMail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
SmtpClient client = new SmtpClient();
client.Send(activationMail);
如果任何人有什麼意見,請在下面謝謝...
以及感謝,這是有用的:)你知道,如果同樣的問題也發生在雅虎或前景? –
任何可敬的電子郵件提供商都是如此。接收服務器通常根據電子郵件中的域驗證發送郵件服務器的域。如果他們不匹配,接收郵件不接受。或者至少這是我的經驗。順便說一下,大多數網絡託管公司給你一個免費的SMTP服務器。 – mason
以及感謝我會考慮它:) –