No connection could be made because the target machine actively refused it 72.14.213.109:587

StackOverflow https://stackoverflow.com/questions/4699257

سؤال

 //Create Mail Message Object with content that you want to send with mail.
        System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("dotnetguts@gmail.com", "myfriend@yahoo.com",
        "This is the mail subject", "Just wanted to say Hello");

        MyMailMessage.IsBodyHtml = false;

        //Proper Authentication Details need to be passed when sending email from gmail
        System.Net.NetworkCredential mailAuthentication = new
        System.Net.NetworkCredential("dotnetguts@gmail.com", "myPassword");

        //Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
        //For different server like yahoo this details changes and you can
        //get it from respective server.
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

        //Enable SSL
        mailClient.EnableSsl = true;

        mailClient.UseDefaultCredentials = false;

        mailClient.Credentials = mailAuthentication;

        mailClient.Send(MyMailMessage);

Thats my code & it throws error : No connection could be made because the target machine actively refused it 72.14.213.109:587

Code Reference : here

Please tell me how can i sought it out ??

هل كانت مفيدة؟

المحلول

Check both of the following points

1- Check that this port 587 is open on your machine

2- Check if your antivirus is blocking the connection to your port

Regards.

نصائح أخرى

If your have any antivirus software running, check the access protection, unblock "prevent mass mailing worms from send mail"

Did you actually change the username and password?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top