none
In sending mail from rediffmail server SMTP,Iam getting the following error RRS feed

  • Question

  • how to resolve authorization failed closing transmission channel please authenticate by doing get message first in c#
    Friday, May 10, 2013 6:18 AM

Answers

  • I never see this message before, but may have a clue to what is causing this condition.  With the Net library version of SMTP you  can't send more than one email on a connection.  You must dispose the SMTP object and then call the constructor again..  SMTP doesn't have a dispose method so what you must do is to put your SMTP code into a seperate class and then dispose the entire class.  So your SMTP code will look like this

    using System;
    using System.Net.Mail;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                //loop the following code
                MYSMTP smtp = new MYSMTP();
                smtp.Dispose();
            }
        }
        class MYSMTP : IDisposable
        {
            SmtpClient client = new SmtpClient();
            //put your smtp code in this class
            public void Dispose()
            {
                if( client != null)
                {
                    client = null;
                }
            }
        }
    }


    jdweng


    Friday, May 10, 2013 7:04 AM

All replies

  • I never see this message before, but may have a clue to what is causing this condition.  With the Net library version of SMTP you  can't send more than one email on a connection.  You must dispose the SMTP object and then call the constructor again..  SMTP doesn't have a dispose method so what you must do is to put your SMTP code into a seperate class and then dispose the entire class.  So your SMTP code will look like this

    using System;
    using System.Net.Mail;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                //loop the following code
                MYSMTP smtp = new MYSMTP();
                smtp.Dispose();
            }
        }
        class MYSMTP : IDisposable
        {
            SmtpClient client = new SmtpClient();
            //put your smtp code in this class
            public void Dispose()
            {
                if( client != null)
                {
                    client = null;
                }
            }
        }
    }


    jdweng


    Friday, May 10, 2013 7:04 AM
  •  public void sendmailRediffmail(string to, string subject, string body, string username, string password, string port, string smtp)
        {
            try
            {
                var emailClient = new SmtpClient(smtp);
                var message = new MailMessage(username, to, subject, body) { IsBodyHtml = true };
                var smtpUserInfo = new NetworkCredential(username, password);
                emailClient.UseDefaultCredentials = false;
                emailClient.EnableSsl = false;
                emailClient.Credentials = smtpUserInfo;
                emailClient.Port = int.Parse(port);
                emailClient.Host = smtp;
                emailClient.Send(message);

            }
            catch (Exception ex)
            {
                ex.Data.Clear();

            }
        }

    Here I'm using the smtp value as smtp.rediffmail.com and port number as 25

    username:manigandanfinetechs@rediffmail.com

    password:mypassword

    I'm using the above code, but still I'm getting the same error which I have mentioned already(authorization failed closing transmission channel please authenticate by doing get message first ).

    So please do me the favour 

    thanks in advance

    With anticipation

    mani

                

    mani


    Tuesday, May 14, 2013 10:25 AM
  • Cehc with your email provider for the SMTP options.  Ther are a number of different combination of port numbers and options that SMTP mail server require.

    I think think the From property is required and it should be the same as the setting in the credentials.  I made some changes below that may help

    public void sendmailRediffmail(string to, string subject, string body, string username, string password, string port, string smtp)
        {
            try
            {
                var emailClient = new SmtpClient("smtp.rediffmail.com");
                emailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                var message = new MailMessage(username, to, subject, body) { IsBodyHtml = true };
                message.From = username;
                var smtpUserInfo = new NetworkCredential(username, password);
                emailClient.UseDefaultCredentials = false;
                emailClient.EnableSsl = false;
                emailClient.Credentials = smtpUserInfo;
                emailClient.Port = int.Parse(port);
                emailClient.Host = smtp;
                emailClient.Send(message);
            }
            catch (Exception ex)
            {
                ex.Data.Clear();
            }


    jdweng

    Tuesday, May 14, 2013 2:33 PM
  • var emailClient = new SmtpClient("smtp.rediffmail.com"); emailClient.DeliveryMethod = SmtpDeliveryMethod.Network; var message = new MailMessage(username, to, subject, body) { IsBodyHtml = true }; message.From = username;

    I'm not able to write the line {message.From = username;}.. It is showing the error can not convert source type string to target type System.net.mail.mailAddress.

    Hence I have written the code as  {message.From = new MailAddress(username);}

    But now also the same problem occured...

    so, help me out to resolve this issue.. or tell me the ways to contact the email provider for the SMTP options.Thanks in advance

    with regards

    mani


    mani

    Wednesday, May 22, 2013 1:12 PM
  • I think there is a firewall blocking port 25 which is very common.  See webpage below.  To get through the firewall you either have to use a relay server, or possibly theh firewall will allow using a secure SMTP port address (other than 25), and the mail server has to accept SMTP at a different port address.  I would show the error to your MIS department.  I don't know what a "doing get message first in c#".

    I think that port 25 is already being used by your company to forwarrd email to an exchange server and your arre trying to send to a different server.

    http://support.microsoft.com/kb/290842


    jdweng

    Wednesday, May 22, 2013 1:50 PM
  • Sorry sir I'm not able to perceive your points clearly..It is not a problem.. Can you suggest me the pdf or book where I can get  basic principles to send the email for better understanding

    With Anticipation

    Thanks &regards

    mani


    mani

    Thursday, May 23, 2013 9:18 AM
  • It is pretty simple.  The standand email format is used to transport mail messages from one mail server to another mail server.  SMTP is used to send email messages from from a VS application to a mail server.  The email server verifies that credentials are correct and then forwards the email to the destination address of the email.

    Port 25 is often blocked by firewalls to prevent hackers from using it to send fake emails. Port 587 is also used by SMTP using SSL encryption.  Some companies/firewalls will also block port 587.

    So to allows email messages to be send with the two main port being blocked (25, 587) often a relay port is used which is a different port number that isn't blocked.  A relay server will receivve the email on the new port number and then perfrom a verification check making sure the email came from a reliable source and then forwards the email message to port 25 or 587.  The relay server is allowed to send messages on port 25, 587 while your PC has these port numbers blocked.

    I believe your error message is coming from a relay server.  The relay is performing a verification and your software is responding properly to the relay server.


    jdweng

    Thursday, May 23, 2013 10:02 AM