Send email programatically in asp.net from discountasp

This worked in my previous site host:

MailMessage mail = new MailMessage();

        mail.IsBodyHtml = true;

        //set the addresses
        mail.From = new MailAddress(strUserEmail);
        mail.To.Add(new MailAddress("Support@StockPickerMax.com"));

mail.Subject... etc
     //  SmtpClient smtp = new SmtpClient("mail.stockpickermax.com", 8889); previous host, worked
       
     SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 8889);
// current host(discountasp) does not work.
         
            smtp.Send(mail);

Error on Send(mail)

No connection could be made because the target machine actively refused it 64.79.170.142:8889]

What should I change? Is 8889 the correct port for discountasp?
DovbermanAsked:
Who is Participating?
 
malikirfan28Connect With a Mentor Commented:
Kindly confirm from your hosted providers that they have configured SMTP on their server and get the SMTP settings from them.
If they have configured it locally  (which most service provider have) then you can use "localhost" as a SMTP server. Here will be an example for you.

MailMessage mail = new MailMessage();

        mail.IsBodyHtml = true;

        //set the addresses
        mail.From = new MailAddress(strUserEmail);
        mail.To.Add(new MailAddress("Support@StockPickerMax.com"));
System.Web.Mail.SmtpMail.SmtpServer = "localhost";
System.Web.Mail.SmtpMail.Send(mail);

0
 
malikirfan28Commented:
You can also check that either local SMTP is configured or not by using following command in command prompt on that machine.

telnet localhost 25.

Kindly also note that normally SMTP is configured on port 25. Check with your providers if they have configured it on another port.

Have a look here. It may also help you.
0
 
nrip_cheemaConnect With a Mentor Commented:
seems like in previous the smtp service was running on non-default port (8889) (or Nated at the end firewall) . You can either request the same or ask for new configuration.

If you are sure that nothing is changed at the server end; so you can also check the firewall at the pc/server on which you are running the code. It may happen that communication is blocked on that machine on non standard ports.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
SamMacPCConnect With a Mentor Commented:
Hosts are really good about telling you what their setup is. They will normally have pre-scripted forms available in their cpanel. Who is your host? Have you given them a copy of that script? What do they say? Is there a specific port or server they want you to send through? Does the host require authentication?

Probably not.

--Sam
0
 
DovbermanAuthor Commented:
The host provided the information I needed:

               SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 25);
                NetworkCredential Credentials = new NetworkCredential("support@stockpickermax.com", "mypassword");
                smtp.Credentials = Credentials;
                 smtp.Send(mail);

Thanks for your help.
0
 
DovbermanAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.