login about faq

Hi, I'm trying to send multiple notifications and want to verify the smtp login before starting any preparation for sending the notifications, but my problem is the calls to VerifySmtpLogin don't seem to do anything before my first SentEmail call.

var mailman = new MailMan();

mailman.SmtpHost = _settings.EmailServer;
mailman.SmtpSsl = _settings.UseSsl;
mailman.StartTLS = _settings.UseTls;
mailman.SmtpPort = _settings.SmtpPort;
mailman.SmtpUsername = _settings.SmtpUsername;
mailman.SmtpPassword = _settings.SmtpPassword;

mailman.ReadTimeout = 15;
mailman.ConnectTimeout = 15;

var smtpLoginIsValid = mailman.VerifySmtpLogin(); // false
var verifySmtpConnection = mailman.VerifySmtpConnection(); // false

if (!mailman.SendEmail(email))
throw new Exception(string.Format("Unable to send mail. {0}", mailman.LastErrorText));
// credentials didn't change at all
var smtpLoginIsValid = mailman.VerifySmtpLogin(); // true
var verifySmtpConnection = mailman.VerifySmtpConnection(); // true

Do I need to initialize something before calling verifyxxx?

asked Nov 25 '14 at 10:14

Manuel%20H's gravatar image

Manuel H

edited Nov 25 '14 at 10:15

A call to mailman.OpenSmtpConnection() doesn't help either

(Nov 25 '14 at 11:03) Manuel H

Check out this Chilkat article on the Invalid Token error, it might help:


Essentially it says that you are trying to use SSL on a non-SSL port. Does it work if you use Port 465 instead (with UseSsl = 1), or port 587 with UseSsl = 0?


answered Nov 25 '14 at 12:10

jpbro's gravatar image

jpbro ♦

If you need to use port 587 with UseSsl = 0, I would try with UseTls = 1 first, then if that fails try UseTls = 0 to see if that works.

(Nov 25 '14 at 12:11) jpbro ♦

Thanks a lot, UseSsl = 0 & UseTls = 1 with Port 587 returned the correct Value for VerifySmtpLogin. But it is still hard to understand why SendMail will work if VerifySmtpLogin returns false. I would expext if VerifySmtpLogin = 0 then SendMail will throw an exception otherwise SendMail will work fine.

(Nov 26 '14 at 05:15) Manuel H

I wonder if it's due to either the AutoFix property or RequireSslCertVerify property being 1. This is speculation, but perhaps the VerifySmtpLogin method short-circuits and returns 0 before one or both of those properties has a chance to "fix" the connection when sending? Only Chilkat could answer this for sure though.

(Nov 26 '14 at 06:54) jpbro ♦

The project ist about 3 years old, inclused is the Version: ChilkatDotNet2.dll Version The Target .NET Framework is 3.5.

  • I deleted the UnlockComponent just for the comment here in the forum
  • The credentials are good, the SendMail works, i have an email in my inbox after executing the code
  • I dindnt see a VerboseLogging, maybe my chillkat version is to old? The Value from LastErrorText is:

        DllDate: Sep  8 2009
        UnlockPrefix: UGlauxMAIL
        Username: haegeli
        Component: .NET 2.0 / x64
        Need new SMTP connection
          Connecting to SMTP server smtp.office365.com:587
          smtp_host: smtp.office365.com
          smtp_port: 587
          smtp_user: apptest@glauxsoft.com
          protocol: default
          Invalid token.
          ReceivedDataQP: 220 DB4PR04CA0002.outlook.office365.com Microsoft ESMTP MAIL Service rea=
    dy at Tue, 25 Nov 2014 16:40:03 +0000

    SEC_E_INVALID_TOKEN Aborting SSL client handshake because of fatal error Error performing handshake Failed to connect to SMTP server. Failed to connect to SMTP server. Failed. "

I repeated the same thing with v9.5.0.45 for the .NET 3.5 frameworks with the same result.


answered Nov 25 '14 at 11:54

Manuel%20H's gravatar image

Manuel H

I tried with using known good credentials and settings and it worked as expected (VerifySmtpLogin returned 1 on the first call).

A few things:

  • Are you using the latest version of the Chilkat components?
  • I don't see a call to UnlockComponent - is your component unlocked?
  • Have you tried with known good credentials instead of using values stored in your _settings object to see if you get the expected results?
  • Try setting the VerboseLogging to 1, then output the contents of the LastErrorText property immediately after your first failing VerifySmtpLogin call and post those results here. There might be a clue in the error log as to why it is failing to perform as you expect.

answered Nov 25 '14 at 11:24

jpbro's gravatar image

jpbro ♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Nov 25 '14 at 10:14

Seen: 3,412 times

Last updated: Nov 26 '14 at 06:54

powered by OSQA