简体   繁体   中英

Cant Send Email When Using Dedicated Server

I am getting this Error ,

Send Email Failed.Mailbox unavailable. The server response was: 5.7.1 
Unable to relay for myEmail@itaxsmart.com 

Before this i was using godeady for databse and publish site .this code working Before, Now i have transfer and published my Database and site on my Dedicated server and i am Getting unable to Replay from server's IP Error

Note: system.net.mail namespace is used for emailing.

 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

copy the following code.. its working for my gmail account

in web.config

<mailSettings>
  <smtp from="youremail@gmail.com">
    <network host="smtp.gmail.com" port="587" userName="youremail" password="xx" defaultCredentials="false"/>

  </smtp>
</mailSettings>

In code behind ( on button click)

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)

It will work for sure..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM