akalogeropoulos
10 years agoOccasional Contributor
Error code "530 5.7.1 Client was not authenticated" sending email.
I'm getting the erreur code "530 5.7.1 Client was not authenticated" when i try to send an email. I was working before but since IT has update the email server it stop working. They provide me with username and password to use in my code but it still does not work. Code:
function SendEmail(mFrom, mTo, mSubject, mBody, mAttach) { var i, schema, mConfig, mMessage; try { schema = "http://schemas.microsoft.com/cdo/configuration/"; mConfig = Sys.OleObject("CDO.Configuration"); mConfig.Fields.Item(schema + "sendusing") = 2; // cdoSendUsingPort
mConfig.Fields.Item(schema + "smtpserver") = "ServerName"; // SMTP server
mConfig.Fields.Item(schema + "smtpserverport") = 25; // Port number
mConfig.Fields.Item(schema + "smtpauthenticate") = 0; // Authentication mechanism
mConfig.Fields.Item(schema + "sendusername") = Username; // User name (if needed)
mConfig.Fields.Item(schema + "sendpassword") = Password; // User password (if needed)
mConfig.Fields.Update(); mMessage = Sys.OleObject("CDO.Message"); mMessage.Configuration = mConfig; mMessage.From = mFrom; mMessage.To = mTo; mMessage.Subject = mSubject; mMessage.HTMLBody = mBody; if(mAttach != "") { aqString.ListSeparator = ","; for(i = 0; i < aqString.GetListLength(mAttach); i++) mMessage.AddAttachment(aqString.GetListItem(mAttach, i)); } mMessage.Send(); } catch (exception) { Log.Error("E-mail cannot be sent", exception.description); CollectGarbage(); return false; } Log.Message("Message to <" + mTo + "> was successfully sent"); CollectGarbage(); return true;
Best regards, Anastasios.