0 votes

I am using ProxyFactory for sending mail

This is my code:
ProxyFactory factory = new ProxyFactory();
IProxyClient proxy = factory.CreateProxy(
ProxyType.Http, "my ip", my port);
Socket socket = proxy.Connect("smtpserver", Smtp.DefaultPort);

I get this exeption:
Proxy responded with a 400 code - Bad Request.

Anyone can help me?
Thanks!
Ora

by

1 Answer

0 votes

Please make sure you are using the latest version of Mail.dll.

If your proxy server requires authentication use CreateProxy method overload that takes user and pass parameters.

Make sure proxy put is correct.

Also make sure your SMTP server accepts connections on non-ssl port (587).

by (301k points)
First, Thank you to about fast answer

I download mail.dll from NuGet Package Manager console by command :Install-Package Mail.dll

I added my user and my password of my computer but I get this error yet.

I put "my ip" according to cmd command: ipconfig and select IPv4 Address.

How do I check that I my SMTP server accepts connections on non-ssl port (587)?

Tanks!
You suppose to enter proxy server address or proxy server IP address not your own IP.
Great, It is work! Thank you!

I continue my program in order to send email by proxy
This is my code:
ProxyFactory factory = new ProxyFactory();
IProxyClient proxy = factory.CreateProxy(
ProxyType.Http, "proxy server address", port, "username", "password");
Socket socket = proxy.Connect("smtpserver", Smtp.DefaultPort);
using (Smtp smtp = new Smtp())
{
    smtp.Attach(socket);
    // ...
    smtp.Close();
}

I get error in line: smtp.Attach(socket);

Error:
Tried to read a line. Only '' received. Please make sure that antivirus and firewall software are disabled or configured correctly.

I need to stop antivirus?? other idea?
What is the port your SMTP server is using? Does it need SSL? Have you disabled your antivirus software?
DefaultPort = 587
Is the exception coming from Attach method?

If so, your code is correct and this SMTP server is not responding properly. You'll need to contact your server administrator.
yes, I'll have to check it
Thanks a lot!
...