0 votes

A Mailserver that does not need authorization - but use the user-login-value (to act differently for some userIds) -
could not use Smtp.UseBestLogin(userId,pw); A Exception is thrown. Other Mailframeworks act different and allow this.
Is there another way to send a Mail with a userId when authorization is not mandatory (for example on some SNMP-Relays).

by (400 points)
What command exactly you want to send to SMTP server instead of proper authentication?
We want to Send via

smtp.Connect("OurExchangeServer")
// and some Kind of Login or UseBestLogin
smtp.Login("UsernameForOtherMailBehaviour","")
smtp.SendMessage(email);

The result is an exception at smtp.Login() or smtp.UseBestLogin() when we use a server that does not need authorization. We want to  give them the user to seperate mail-behaviour on the username with our Exchange Mail-Relay. A old mail-framework like CDOSys works with this special mail-behaviuor.
If your server rejects authorization don't use Login or UseBestLogin.

What kind of 'special mail-behaviuor' are you talking about exactly?
I think you should ask server administrator what exactly you should do.

1 Answer

+1 vote

You can skip authentication by simply removing UseBestLogin line:

using(Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.server.com");

    // smtp.UseBestLogin("user", "password");

    smtp.SendMessage(email);                     
    smtp.Close();   
}

Depending on what exact command you want to your server, you can send empty password:

using(Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.server.com");

    smtp.Login("user", ""); // AUTH LOGIN auth no password

    smtp.SendMessage(email);                     
    smtp.Close();   
}

or you can send any custom command you need:

using(Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.server.com");

    smtp.SendCommand("X-COMMAND");

    smtp.SendMessage(email);                     
    smtp.Close();   
}
by (297k points)
...