-#ifdef CYRUS_SASL
- /*
- * If the user asked for SASL, then check to see if the SMTP server
- * supports it. Otherwise, error out (because the SMTP server
- * might have been spoofed; we don't want to just silently not
- * do authentication
- */
-
- if (sasl) {
- if (! (server_mechs = EHLOset("AUTH"))) {
- sm_end(NOTOK);
- return sm_ierror("SMTP server does not support SASL");
- }
-
- if (saslmech && stringdex(saslmech, server_mechs) == -1) {
- sm_end(NOTOK);
- return sm_ierror("Requested SASL mech \"%s\" is not in the "
- "list of supported mechanisms:\n%s",
- saslmech, server_mechs);
- }
-
- if (sm_auth_sasl(user, saslssf, saslmech ? saslmech : server_mechs,
- server) != RP_OK) {
- sm_end(NOTOK);
- return NOTOK;
- }
- }
-#endif /* CYRUS_SASL */
+ /*
+ * If the user asked for SASL, then check to see if the SMTP server
+ * supports it. Otherwise, error out (because the SMTP server
+ * might have been spoofed; we don't want to just silently not
+ * do authentication
+ */
+
+ if (sasl) {
+ char *server_mechs;
+ if (! (server_mechs = EHLOset("AUTH"))) {
+ sm_end(NOTOK);
+ return sm_ierror("SMTP server does not support SASL");
+ }
+ if (netsec_negotiate_sasl(nsc, server_mechs, &errstr) != OK) {
+ sm_end(NOTOK);
+ return sm_nerror(errstr);
+ }
+ }