[英]Cant Send Email When Using Dedicated Server
我收到此錯誤,
Send Email Failed.Mailbox unavailable. The server response was: 5.7.1
Unable to relay for myEmail@itaxsmart.com
在此之前,我一直在使用Godeady來存儲數據庫並發布site.this代碼,在此之前,現在我已經在Dedicated server
上傳輸並發布了Database
和站點,並且無法從服務器的IP錯誤重播。
注意: system.net.mail命名空間用於通過電子郵件發送。
protected void btnsubmit_Click(object sender, ImageClickEventArgs e)
{
//Code for send Email
MailMessage sendMailforSA = new MailMessage();
SmtpClient smtpforSA = new SmtpClient();
string subjectforSA = null;
subjectforSA = "Thanks for apply";
System.Net.NetworkCredential credforSA = new System.Net.NetworkCredential("Superman@gmail.com", "password");
sendMailforSA.To.Add(txtemailid.Value);
MailAddress cc = new MailAddress("info@superman.com");
sendMailforSA.CC.Add(cc);
// sendMailforSA.CC("abcxxx@gmail.com");
sendMailforSA.From = new MailAddress("Rajnikant@gmail.com");
sendMailforSA.Subject = subjectforSA.ToString();
sendMailforSA.Body =" Thank you.... your message you can use html tag for style effect";
sendMailforSA.IsBodyHtml = true;
smtpforSA.Host = "smtp.gmail.com";
smtpforSA.Port = 25;
smtpforSA.EnableSsl = false;
smtpforSA.UseDefaultCredentials = false;
smtpforSA.Credentials = credforSA;
smtpforSA.Send(sendMailforSA);
}
http://satindersinght.blogspot.in/2012/01/how-to-send-email-in-asp.html
復制以下代碼..其適用於我的Gmail帳戶
在web.config中
<mailSettings>
<smtp from="youremail@gmail.com">
<network host="smtp.gmail.com" port="587" userName="youremail" password="xx" defaultCredentials="false"/>
</smtp>
</mailSettings>
在后面的代碼中(單擊按鈕)
Dim smtp As New System.Net.Mail.SmtpClient()
Dim smail As New System.Net.Mail.MailMessage
smail.To.Add(New System.Net.Mail.MailAddress("emailtowhomyouwanttosend@yahoo.com "))
smail.From = New System.Net.Mail.MailAddress("youremail@gmail.com", "Visit me")
smail.Subject = "hiii"
smail.IsBodyHtml = "true"
smail.Body = "HELLO THERE"
smtp.EnableSsl = True
smtp.Send(smail)
它肯定會工作..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.