Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows application that sends an SMTP email. It works fine from my pc but it does not from another. The code I'm using is:

string body = "my message" + txtFriendName.Text + Environment.NewLine +
      Environment.NewLine + " my url link - " + "http://www.mywebsite.com";
MailMessage email = new MailMessage("sender email", txtFriendEmail.Text, txtName.Text + "subject", body);

SmtpClient SmtpMail = new SmtpClient("smtp.fasthosts.co.uk", 25);
SmtpMail.Credentials = new NetworkCredential("sender email", "password");
SmtpMail.EnableSsl = false;
SmtpMail.Send(email);


Any ideas why it does not work from any pc?
Posted
Comments
Albin Abel 10-Feb-11 18:16pm    
Have you tried without the credentials

The client machine may have a firewall that blocks outgoing SMTP, or the firewall may be on his network gateway/router. In some cases, specially with home connections, ISPs do not permit outgoing SMTP either (I have had this problem with Comcast in the US and Rogers in Canada).
 
Share this answer
 
v2
Comments
milenalukic 10-Feb-11 19:10pm    
I will check, but this is probably the problem. Is there a workaround to bypass the block?
Nish Nishant 10-Feb-11 19:11pm    
No, you are going to have to ask them to configure the firewall to allow outgoing connections on port 25.
milenalukic 14-Feb-11 16:12pm    
Thanks very much.

I have now configured the program to send mail from the server side and it works perfectly.
Nish Nishant 14-Feb-11 16:15pm    
You are welcome. Glad to hear it's all working fine now.
What is not working? put your code in try/catch block and see what is throwing exception. That might give you a hint. If not update your question with relevant information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900