0
Answer

Send email through the proxy server?

Ask a question
vallab rao

vallab rao

14y
8.1k
1
Hi,

I m implementing an tool which sends mail to any id to any id  but i can send the mail through the direct use  SMTP server and username and password. But when it comes to through the proxy then it fails. Don't know what went wrong ?
Here is code i m written:

protected void btnSendMail(object sender, EventArgs e)
    {
     
        MailAddress from = new MailAddress(txtFrom.Text.ToString());
        MailAddress To = new MailAddress(Ttxt.Text.ToString());

        MailMessage mail = new MailMessage(from, To);

       
        mail.Subject = txtSubject.Text.ToString();
        mail.Body = Editor1.Content.ToString();
        mail.IsBodyHtml = true;

        SmtpClient cnt = new SmtpClient();
        cnt.Host = SDomainName.Text.ToString();//domain.com
        cnt.Port = 1080;//port
        cnt.Credentials = new System.Net.NetworkCredential(from.ToString(),txtPass.Text.ToString());       //username,password

        //SmtpMail.Send(mail);
        cnt.EnableSsl = true;

        try
        {
            cnt.Send(mail);
         status.Text = "Mail sent successfully";
        }
        catch (Exception ex)
        {
        status.Text = ex.Message.ToString();
        }
    }

Please help in implementing the code.