Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to send a mail with the MailMessage & SmtpClient class.
However it looks like it doesnt support any proxies what so ever.

I've been reading around but I cant seem to find any solutions to my issue.

I've tried changing the smtpclient so that it connects through a proxy but that doesnt work.


MailAddress from = new MailAddress("emailAdress");
MailAddress to = new MailAddress("emailAdress");

MailMessage mm = new MailMessage(from, to);
mm.Subject = "Subject";
mm.Body = "Body";

SmtpClient client = new SmtpClient("124.88.67.17", 82); //This should be smtp.gmail.com or outlook etc.
client.Credentials = new System.Net.NetworkCredential("emailAdress", "password");

client.Send(mm);
MessageBox.Show("Done!");


Is there any other ways to send a email through a proxy using the same method?

What I have tried:

I've tried playing around with the parameters but that didnt change anything.
Posted
Updated 15-Jan-17 3:25am

1 solution

SmtpClient client = new SmtpClient("124.88.67.17", 82); 
client.Credentials = new System.Net.NetworkCredential("emailAdress", "password");


These two lines should refer to the proxy and not to the SMTP server...
 
Share this answer
 
Comments
Johnny2121 15-Jan-17 9:46am    
So an example would be?
Because the new SmtpClient("124.88.67.17", 82); is the proxy server but I'm not to sure what you mean with this line
client.Credentials = new System.Net.NetworkCredential("emailAdress", "password");
because you need to login to your email to send one.
Kornfeld Eliyahu Peter 15-Jan-17 9:50am    
If you use proxy ,you have to login to the proxy, not to the email server, which is hidden from you by the proxy... So the credentials have to be one for the proxy too...
Johnny2121 15-Jan-17 10:09am    
How on earth do i log into a proxy that I found on the internet?
Kornfeld Eliyahu Peter 15-Jan-17 10:12am    
The idea of proxy is that you can not cross it without authentication - to keep the bad out...
Johnny2121 15-Jan-17 10:15am    
So how would I actually send a message with a proxy? Seems like you cant because you need to log into the proxys erver which apparently you cant? I'm confused.

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