Home

Send Mail (SMTP) through Office 365 with MFA

%3CLINGO-SUB%20id%3D%22lingo-sub-163867%22%20slang%3D%22en-US%22%3ESend%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-163867%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20a%20web%20server%20that%20needs%20to%20be%20able%20to%20send%20emails%20as%20users%20(FROM%20field)%3B%20however%2C%20we%20have%20noticed%20that%20if%20the%20user%20account%20is%20protected%20with%20MFA%2C%20the%20message%20is%20rejected.%26nbsp%3B%20Has%20anyone%20been%20able%20to%20get%20this%20working%3F%20I%20found%20a%20work%20around%20by%20using%20an%20account%20that%20does%20not%20have%20MFA%20then%20adding%20that%20account%20as%20a%20delegate%20of%20the%20sending%20user%2C%20but%20that%20seems%20a%20bit%20extensive.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20our%20scenario%2C%20web%20server%20sends%20a%20message%20showing%20it%20comes%20from%20a%20sales%20rep%2C%20that%20is%20populated%20dynamically%20on%20the%20web%20server.%20It%20uses%20CFMAIL%20(same%20rules%20as%20say%20PHPMailer)%20and%20uses%20the%20FROM%20field%20as%20the%20sales%20rep.%20That%20is%20handled%20off%20in%20this%20case%20to%20Office365%20to%20send%20emails.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActual%20Error%3A%26nbsp%3B%20Diagnostic-Code%3A%20smtp%3B550%205.7.60%20SMTP%3B%20Client%20does%20not%20have%20permissions%20to%20send%20as%20this%20sender%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-163867%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAuthentication%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIdentity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-167184%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-167184%22%20slang%3D%22en-US%22%3EOption%202%20will%20work%20externally.%20You%20need%20to%20make%20sure%20your%20certificates%20for%20the%20connector%20contain%20your%20domain%2C%20or%20it%20will%20be%20treated%20as%20external%20email%20relaying.%20Option%203%20is%20better.%20Option%202%20is%20not%20there%20for%20allow%20mass%20marketing%20emails.%20But%20will%20work%20for%20a%20lower%20number%20of%20emails.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166973%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166973%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20have%20an%20Azure%20AD%20app%20registration%20with%20permissions%20to%20send%20mail%20on%20behalf%20of%20a%20user%2C%20you%20can%20get%20an%20access%20token%20for%20that%20user%20and%20use%20it%20for%20such%20purposes.%26nbsp%3B%20The%20token%20is%20acquired%20during%20an%20interactive%20login%2C%20so%20MFA%20is%20supported%2C%20and%20then%20you%20can%20use%20that%20token%20to%20send%20email%20via%20the%20Office%20365%20REST%20API%20(and%20to%20a%20lesser%20extent%2C%20Microsoft%20Graph).%26nbsp%3B%20We%20have%20solutions%20that%20do%20this%20in%20exactly%20this%20scenario%20and%20work%20fine%20with%20MFA%20secured%20accounts.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166403%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166403%22%20slang%3D%22en-US%22%3E%3CP%3EPer%20Microsoft's%20article%20that%20I%20originally%20included%2C%20Option%202%20will%20not%20work%20for%20sending%20emails%20to%20external%20users%20(live.com%2C%20gmail.com%2C%20etc.)%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20far%20as%20what%20users%20will%20be%20logging%20into%3B%20Azure%20AD.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166340%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166340%22%20slang%3D%22en-US%22%3EYes%2C%20which%20is%20why%20I%20said%20options%202%20or%203%2C%20and%20both%20will%20work%20for%20you%20even%20if%20your%20Exchange%20hybrid%20role%20server%20is%20in%20Azure.%3CBR%20%2F%3E%3CBR%20%2F%3EBy%20the%20way%2C%20if%20they%20don't%20plan%20on%20maintaining%20an%20on-premises%20AD%2C%20what%20are%20the%20users%20going%20to%20login%20to%3F%20Unless%20you%20are%20going%20cloud%20accounts%20completely%20and%20turning%20off%20AD%2C%20you%20still%20need%20local%20domain%20controllers%20to%20the%20users%20for%20efficient%20login.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166256%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166256%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20reason%20I%20mention%20we%20are%20moving%20away%20from%20the%20Hybrid%20solution%20is%20that%20we%20are%20moving%20away%20from%20having%20everything%20on-premise%20and%20to%20AzureAD%20and%20Azure%20VMs.%20Our%20current%20setup%20does%20point%20to%20our%20on-premise%20Exchange%20server%3B%20however%2C%20we%20plan%20to%20phase%20that%20out%20as%20we%20consolidate%20solutions%2C%20move%20to%20Azure%20VM%20and%20migrate%20to%20Office%20365%20SharePoint.%20%26nbsp%3B%20The%20goal%20is%20to%20be%20moved%20off%20of%20our%20on-premise%20servers%20by%20end%20of%20the%20year%2C%20which%20is%20why%20I%20do%20not%20want%20to%20point%20any%20new%20projects%20to%20our%20On-premise%20Exchange%20server.%26nbsp%3B%20The%20do%20not%20plan%20on%20maintaining%20an%20on-premise%20AD%2C%20which%20is%20the%20only%20reason%20to%20keep%20running%20in%20a%20Hybrid%20scenario.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20error%20message%20I%20originally%20included%20was%20when%20I%20was%20assigning%20the%20non-MFA%20account%20to%20our%20SMTP%20configuration%20and%20sending%20using%20an%20MFA%20account.%20Since%20Option%201%20does%20not%20work%20with%20MFA%20accounts%2C%20that%20is%20where%20I%20am%20running%20into%20an%20issue.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166174%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166174%22%20slang%3D%22en-US%22%3EWhen%20I%20said%20that%20MFA%20has%20nothing%20to%20do%20with%20this%2C%20I%20mean%20this%20specific%20error.%20The%20error%20%22Diagnostic-Code%3A%20smtp%3B550%205.7.60%20SMTP%3B%20Client%20does%20not%20have%20permissions%20to%20send%20as%20this%20sender%22%20means%20that%20the%20account%20you%20are%20logging%20in%20with%20does%20not%20have%20permission%20to%20send%20as%20the%20From%20address%20you%20are%20specifying.%3CBR%20%2F%3E%3CBR%20%2F%3ETherefore%20for%20%231%20you%20would%20need%20to%20login%20with%20the%20actual%20From%20address%20and%20not%20another%20account%2C%20but%20then%20MFA%20would%20impact%20you.%20This%20is%20why%20I%20did%20not%20suggest%20you%20try%20Option%20%231%20and%20only%20either%20%232%20or%20%233.%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20either%20of%20these%2C%20it%20does%20not%20matter%20if%20the%20recipient%20is%20internal%20or%20external.%20This%20is%20regardless%20what%20it%20says%20in%20the%20support%20article%20under%20Direct%20Send%20about%20it%20being%20for%20internal%20mailboxes%20only%20(see%20the%20other%20scenarios%20text%20where%20it%20talks%20about%20using%20Direct%20Send%20for%20mailing%20lists%20-%20which%20are%20external%20by%20their%20nature).%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20for%20%233%2C%20you%20realise%20when%20you%20say%20%22We%20will%20eventually%20move%20away%20from%20this%20and%20our%20internal%20mail%20server%20which%20is%20why%20we%20are%20not%20deploying%20new%20services%20that%20point%20to%20our%20internal%20mail%20server.%20%22%20that%20with%20hybrid%20you%20will%20never%20move%20away%20from%20this%20scenario.%20With%20hybrid%20you%20need%20to%20maintain%20an%20on-premises%20Exchange%20Server%20for%20cloud%20mailbox%20management%20as%20you%20are%20doing%20AD%20Sync.%20Given%20that%20you%20have%20an%20on-premises%20server%2C%20you%20would%20use%20that%20as%20your%20apps%20and%20devices%20SMTP%20relay%20device%20as%20well.%20Microsoft%20have%20said%20they%20are%20working%20on%20improving%20the%20management%20experience%20with%20hybrid%20at%20Ignite%20last%20year%2C%20but%20that%20does%20not%20cover%20the%20need%20for%20SMTP%20relay%20scenarios%20like%20you%20describe.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-165721%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-165721%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20using%20Option%201%2C%20MFA%20has%20everything%20to%20do%20with%20it.%20Option%201%20requires%20authentication%20to%20work%20and%20I%20have%20since%20been%20able%20to%20confirm%20from%20Microsoft%20that%20Option%201%20will%20not%20work%20when%20MFA%20is%20enabled.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EOption%202%20will%20not%20work%20in%20our%20environment%2C%20as%20the%20emails%20generated%20will%20often%20be%20sent%20externally.%20Option%202%20(Direct%20Send)%20will%20only%20send%20to%20internal%20O365%20recipients.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOption%203%20is%20still%20in%20question.%20We%20already%20have%20send%20connectors%20in-place%20due%20to%20our%20hybrid%20configuration.%20Still%20waiting%20on%20a%20response%20from%20Microsoft%20if%20we%20can%20modify%20these%20settings%20to%20all%20relay%20but%20without%20causing%20issues%20with%20our%20Hybrid.%26nbsp%3B%20We%20will%20eventually%20move%20away%20from%20this%20and%20our%20internal%20mail%20server%20which%20is%20why%20we%20are%20not%20deploying%20new%20services%20that%20point%20to%20our%20internal%20mail%20server.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-165597%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-165597%22%20slang%3D%22en-US%22%3EMFA%20has%20got%20nothing%20to%20do%20with%20this.%20Have%20you%20tried%20sending%20the%20email%20as%20anonymous%20(no%20login%20in%20the%20sending%20client)%20and%20configuring%20connectors%20in%20Exchange%20to%20support%20direct%20send%20to%20Exchange%20Online%3F%20This%20is%20covered%20in%20Option%202%20or%203%20under%20%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-gb%2Farticle%2Fhow-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-365-69f58e99-c550-4274-ad18-c805d654b4c4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.office.com%2Fen-gb%2Farticle%2Fhow-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-365-69f58e99-c550-4274-ad18-c805d654b4c4%3C%2FA%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805177%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805177%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6398%22%20target%3D%22_blank%22%3E%40Jeff%20Harlow%3C%2FA%3E%26nbsp%3B%2C%20did%20you%20solve%20the%20issue%3F%20I%20am%20facing%20exactly%20the%20same%20problem%20here%20-%20the%20send-mailmessage%20was%20working%20at%20smtp.outlook365.com%20before%20enabling%202FA%20and%20after%20that%20I%20receive%20the%20same%20message%20you%20mentioned%20with%20no%20other%20changes.%20I%20also%20tried%20to%20use%20application%20specific%20password%20without%20success.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805186%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805186%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20using%20Option%203%20now.%20Just%20configured%20the%20connector%20to%20allow%20the%20IPs%20for%20servers%20(in%20our%20case%20our%20external%20IP)%20to%20send%20mail%20and%20all%20works.%20No%20authentication%20required.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F392400%22%20target%3D%22_blank%22%3E%40Kazu1301%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805309%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805309%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6398%22%20target%3D%22_blank%22%3E%40Jeff%20Harlow%3C%2FA%3E%26nbsp%3Bthanks%20for%20your%20quick%20answer.%20I%20will%20consider%20the%20solution%203.%20The%20error%20message%20is%20very%20misleading.%20If%20the%20implementation%20of%202FA%20was%20not%20the%20only%20change%20made%2C%20I%20would%20misunderstand%20it%20and%20check%20other%20possibilities.%20Anyway%2C%20thanks%20a%20lot!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805354%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805354%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6398%22%20target%3D%22_blank%22%3E%40Jeff%20Harlow%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F392400%22%20target%3D%22_blank%22%3E%40Kazu1301%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20still%20use%20Option%20one%20..%20all%20what%20you%20have%20to%20do%20is%20generate%20an%20app%20password%20to%20by%20pass%20MFA.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFollow%20the%20steps%20in%20the%20below%20article%20..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3E%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fcreate-an-app-password-for-office-365-3e7c860f-bda4-4441-a618-b53953ee1183%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2Fcreate-an-app-password-for-office-365-3e7c860f-bda4-4441-a618-b53953ee1183%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3EThanks%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3ERobin%20Nishad%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805434%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805434%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F165275%22%20target%3D%22_blank%22%3E%40Robin%20Nishad%3C%2FA%3E%2C%20it%20was%20the%20first%20thing%20I%20tried.%20In%20the%20same%20way%20I%20do%20with%20Outlook%2C%20I%20generated%20the%20app%20password%20and%20tried%20it%20with%20no%20success.%20I%20am%20creating%20a%20SecureString%20file%20(encrypted%20pwd%20file)%20and%20generating%20a%20PSCredential%20Object%20from%20it%20for%20authentication%20using%20Powershell%2C%20as%20follows%20(I%20hope%20the%20variables%20are%20self%20explanatory)%3A%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24SecureStringPassword%20%3D%20Get-Content%20-Path%20%24EncryptedPasswordFile%20%7C%20ConvertTo-SecureString%3C%2FP%3E%3CP%3E%24EmailCredential%20%3D%20New-Object%20-TypeName%20System.Management.Automation.PSCredential%20-ArgumentList%20%24SMTPUsername%2C%24SecureStringPassword%3C%2FP%3E%3CP%3E....%3C%2FP%3E%3CP%3ESend-MailMessage%20-From%20%24MailFrom%20-To%20%24MailTo%20-Subject%20%24MailSubject%20-Body%20%24MailBody%20-Port%20%24SMTPPort%20-Credential%20%24EmailCredential%20-Attachments%20%24Attachment%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20approach%20works%20very%20well%20without%202FA%2C%20but%20not%20with%20app%20password.%20Do%20you%20see%20any%20mistake%20here%20or%20any%20changes%20that%20may%20work%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKazu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805450%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20Mail%20(SMTP)%20through%20Office%20365%20with%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805450%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6398%22%20target%3D%22_blank%22%3E%40Jeff%20Harlow%3C%2FA%3E%26nbsp%3Bsomeone%20answered%20below%2C%20not%20sure%20why%20that%20took%20so%20long.%20The%20easy%20answer%20is%20that%20you%20generate%20and%20then%20use%20an%20app%20password%20for%20that%20account%2C%20instead%20of%20the%20regular%20user%20password.%26nbsp%3B%20That%20in%20effect%20serves%20as%20the%20second%20authentication%20method%20for%20the%20dual%20authentication.%26nbsp%3B%20%26nbsp%3BHowever...%3C%2FP%3E%3CP%3EWe%20too%20use%20SMTP%20to%20send%20email%20from%20various%20robots%2C%20web%20sites%2C%20and%20marketing%20systems.%26nbsp%3B%20What%20I%20have%20done%20to%20reduce%20the%20complexity%20somewhere%20(perhaps%3F)%2C%20is%20to%20adopt%20a%20third%20party%20mailing%20system%20with%20complete%20DKIM%2FDMARC%2FSPF%20records%20in%20place%20for%20this%20third%20party%20sender.%26nbsp%3B%20This%20really%20does%20eliminate%20so%20much%20of%20the%20hassle%20with%20using%20an%20Office%20365%20SMTP%20account%20to%20send%20email.%26nbsp%3B%20I%20really%20think%20that%20the%20app%20password%20is%20kind%20of%20hack%2C%20it's%20just%20another%20password%20that%20can%20be%20cracked!%26nbsp%3B%20We%20are%20using%20Mailjet.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

We have a web server that needs to be able to send emails as users (FROM field); however, we have noticed that if the user account is protected with MFA, the message is rejected.  Has anyone been able to get this working? I found a work around by using an account that does not have MFA then adding that account as a delegate of the sending user, but that seems a bit extensive. 

 

In our scenario, web server sends a message showing it comes from a sales rep, that is populated dynamically on the web server. It uses CFMAIL (same rules as say PHPMailer) and uses the FROM field as the sales rep. That is handled off in this case to Office365 to send emails. 

 

Actual Error:  Diagnostic-Code: smtp;550 5.7.60 SMTP; Client does not have permissions to send as this sender

 

 

14 Replies
MFA has got nothing to do with this. Have you tried sending the email as anonymous (no login in the sending client) and configuring connectors in Exchange to support direct send to Exchange Online? This is covered in Option 2 or 3 under https://support.office.com/en-gb/article/how-to-set-up-a-multifunction-device-or-application-to-send...

When using Option 1, MFA has everything to do with it. Option 1 requires authentication to work and I have since been able to confirm from Microsoft that Option 1 will not work when MFA is enabled. 


Option 2 will not work in our environment, as the emails generated will often be sent externally. Option 2 (Direct Send) will only send to internal O365 recipients. 

 

Option 3 is still in question. We already have send connectors in-place due to our hybrid configuration. Still waiting on a response from Microsoft if we can modify these settings to all relay but without causing issues with our Hybrid.  We will eventually move away from this and our internal mail server which is why we are not deploying new services that point to our internal mail server. 

 

When I said that MFA has nothing to do with this, I mean this specific error. The error "Diagnostic-Code: smtp;550 5.7.60 SMTP; Client does not have permissions to send as this sender" means that the account you are logging in with does not have permission to send as the From address you are specifying.

Therefore for #1 you would need to login with the actual From address and not another account, but then MFA would impact you. This is why I did not suggest you try Option #1 and only either #2 or #3.

For either of these, it does not matter if the recipient is internal or external. This is regardless what it says in the support article under Direct Send about it being for internal mailboxes only (see the other scenarios text where it talks about using Direct Send for mailing lists - which are external by their nature).

As for #3, you realise when you say "We will eventually move away from this and our internal mail server which is why we are not deploying new services that point to our internal mail server. " that with hybrid you will never move away from this scenario. With hybrid you need to maintain an on-premises Exchange Server for cloud mailbox management as you are doing AD Sync. Given that you have an on-premises server, you would use that as your apps and devices SMTP relay device as well. Microsoft have said they are working on improving the management experience with hybrid at Ignite last year, but that does not cover the need for SMTP relay scenarios like you describe.

The reason I mention we are moving away from the Hybrid solution is that we are moving away from having everything on-premise and to AzureAD and Azure VMs. Our current setup does point to our on-premise Exchange server; however, we plan to phase that out as we consolidate solutions, move to Azure VM and migrate to Office 365 SharePoint.   The goal is to be moved off of our on-premise servers by end of the year, which is why I do not want to point any new projects to our On-premise Exchange server.  The do not plan on maintaining an on-premise AD, which is the only reason to keep running in a Hybrid scenario. 

 

The error message I originally included was when I was assigning the non-MFA account to our SMTP configuration and sending using an MFA account. Since Option 1 does not work with MFA accounts, that is where I am running into an issue. 

Yes, which is why I said options 2 or 3, and both will work for you even if your Exchange hybrid role server is in Azure.

By the way, if they don't plan on maintaining an on-premises AD, what are the users going to login to? Unless you are going cloud accounts completely and turning off AD, you still need local domain controllers to the users for efficient login.

Per Microsoft's article that I originally included, Option 2 will not work for sending emails to external users (live.com, gmail.com, etc.)  

 

As far as what users will be logging into; Azure AD. 

 

If you have an Azure AD app registration with permissions to send mail on behalf of a user, you can get an access token for that user and use it for such purposes.  The token is acquired during an interactive login, so MFA is supported, and then you can use that token to send email via the Office 365 REST API (and to a lesser extent, Microsoft Graph).  We have solutions that do this in exactly this scenario and work fine with MFA secured accounts.

Option 2 will work externally. You need to make sure your certificates for the connector contain your domain, or it will be treated as external email relaying. Option 3 is better. Option 2 is not there for allow mass marketing emails. But will work for a lower number of emails.

@Jeff Harlow , did you solve the issue? I am facing exactly the same problem here - the send-mailmessage was working at smtp.outlook365.com before enabling 2FA and after that I receive the same message you mentioned with no other changes. I also tried to use application specific password without success.  

We are using Option 3 now. Just configured the connector to allow the IPs for servers (in our case our external IP) to send mail and all works. No authentication required. @Kazu1301 

@Jeff Harlow thanks for your quick answer. I will consider the solution 3. The error message is very misleading. If the implementation of 2FA was not the only change made, I would misunderstand it and check other possibilities. Anyway, thanks a lot! 

@Jeff Harlow 

@Kazu1301 

 

You can still use Option one .. all what you have to do is generate an app password to by pass MFA.

 

Follow the steps in the below article ..

 

https://support.office.com/en-us/article/create-an-app-password-for-office-365-3e7c860f-bda4-4441-a6...

 

Thanks

 

Robin Nishad

Hi @Robin Nishad, it was the first thing I tried. In the same way I do with Outlook, I generated the app password and tried it with no success. I am creating a SecureString file (encrypted pwd file) and generating a PSCredential Object from it for authentication using Powershell, as follows (I hope the variables are self explanatory):  

 

$SecureStringPassword = Get-Content -Path $EncryptedPasswordFile | ConvertTo-SecureString

$EmailCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SMTPUsername,$SecureStringPassword

....

Send-MailMessage -From $MailFrom -To $MailTo -Subject $MailSubject -Body $MailBody -Port $SMTPPort -Credential $EmailCredential -Attachments $Attachment

 

This approach works very well without 2FA, but not with app password. Do you see any mistake here or any changes that may work?

 

Regards

 

Kazu

@Jeff Harlow someone answered below, not sure why that took so long. The easy answer is that you generate and then use an app password for that account, instead of the regular user password.  That in effect serves as the second authentication method for the dual authentication.   However...

We too use SMTP to send email from various robots, web sites, and marketing systems.  What I have done to reduce the complexity somewhere (perhaps?), is to adopt a third party mailing system with complete DKIM/DMARC/SPF records in place for this third party sender.  This really does eliminate so much of the hassle with using an Office 365 SMTP account to send email.  I really think that the app password is kind of hack, it's just another password that can be cracked!  We are using Mailjet. 

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
21 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
12 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies