Configuring a Uniform Default Sender Email Address in SAP S/4HANA & NetWeaver via BAdI BCS_SEND_ADDRESSES (SAP Note 3275746)
1. Architectural Problem & Microsoft 365 Relay Rejection (554 SendAsDenied) #
In standard SAP NetWeaver and SAP S/4HANA systems, outbound emails dispatched via Business Communication Services (BCS) / SAPconnect derive the sender email address from the executing user's master record (Transaction SU01 / table ADR6) or from background system identities (e.g. WF-BATCH, ALEREMOTE, BATCH_USER).
When integrating SAP with Microsoft 365 (Exchange Online), Google Workspace, or authenticated enterprise SMTP relays, this default behavior causes immediate delivery failures:
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ SAP OUTBOUND EMAIL RELAY ARCHITECTURE │
│ │
│ [ SAP S/4HANA ] [ Microsoft 365 / Exchange Online ] │
│ Logged-in User: JDOE (john.doe@company.com) │
│ MIME Header From: john.doe@company.com Authenticated Service Account: │
│ SMTP Envelope MAIL FROM: john.doe@company.com ──► sap.noreply@company.com │
│ │ │
│ [ REJECTION ] │
│ 554 5.2.252 SendAsDenied │
│ "Client does not have permissions to │
│ send as this sender" │
└────────────────────────────────────────────────────────────────────────────────────────┘
The Critical Root Cause of Error 554 5.2.252 SendAsDenied
#
When SAP establishes an SMTP session with Microsoft 365 using an authenticated mailbox (e.g., sap.noreply@company.com), Exchange Online validates the SMTP Envelope MAIL FROM:<...> command against the authenticated credentials:
- If a background job or dialog user generates an email with their personal address (
jdoe@company.com), the SMTP server checks ifsap.noreply@company.comhas explicit "Send As" or "Send on Behalf" permissions forjdoe@company.com. - Because user mailboxes do not (and should not) grant global "Send As" delegation to service accounts, Microsoft 365 rejects the transmission:
554 5.2.252 SendAsDenied; <john.doe@company.com> not allowed to send as <sap.noreply@company.com> # or: 550 5.7.60 SMTP; Client does not have permissions to send as this sender
2. Exact S/4HANA BAdI Technical Specification (SAP Note 3275746) #
To resolve this centrally without modifying hundreds of custom print programs (NACE), Smart Forms, Adobe Forms (ADS), or workflow steps, SAP provides SAP Note 3275746 - How to set a default sender email address for outbound emails using Enhancement Spot BCS_SEND_ADDRESSES.
BAdI Metadata Matrix on SAP S/4HANA #
| Component / Attribute | Exact S/4HANA Value | Technical Description & Scope |
|---|---|---|
| Package | SBCOMS |
Business Communication Services core package |
| Enhancement Spot | BCS_SEND_ADDRESSES |
BCS: BAdI to Analyze Addresses when Sending |
| BAdI Definition | BCS_SEND_ADDRESSES |
Single-Use BAdI (Only one active implementation permitted per client) |
| Interface | IF_BCS_BADI_SEND_ADDRESSES |
Kernel BAdI Interface (Invoked by CL_BCS_BADI_ADDRESSES=>PROCESS_BADI) |
| Method | PROCESS_ADDRESSES |
Executed automatically whenever an outbound email is processed by SAPconnect |
| Address Structure | BCSS_BADI_ADDR |
Structure containing ADDRTYPE (type), ADDRESS (email), and VISNAME (display name) |
3. Crucial Technical Requirement for Microsoft 365: ES_STATUS_RECIPIENT & ADDRTYPE = 'INT'
#
In SAP's internal calling class (CL_BCS_BADI_ADDRESSES=>PROCESS_BADI), method PROCESS_ADDRESSES exports two distinct address structures of type BCSS_BADI_ADDR:
ES_SENDER: Controls the MIME HeaderFrom:displayed to the human recipient in their email client (Outlook, Gmail).ES_STATUS_RECIPIENT: Controls the SMTP EnvelopeMAIL FROM:passed during the low-level SMTP protocol handshake.
[!CAUTION]
The Common Implementation Trap with Microsoft 365:
Many developers only populateES_SENDERand leaveES_STATUS_RECIPIENTempty.If you only update
ES_SENDER, the SMTP protocol commandMAIL FROM:<...>still uses the original user's email address! Microsoft 365 evaluatesMAIL FROM:for mailbox authorization, resulting in the exact same554 5.2.252 SendAsDeniedtermination.MANDATORY RULES:
- You MUST assign both
ES_SENDERandES_STATUS_RECIPIENTto your authenticated corporate relay address (e.g.sap.noreply@company.com).- You MUST explicitly set
ADDRTYPE = 'INT'. IfADDRTYPEis not'INT', SAP's internal handlerCL_BCS_BADI_ADDRESSES=>SET_STATUS_RECIPIENTwill bypass updating the envelope address.
4. Step-by-Step Implementation Guide (SE18 / SE19) #
Step 1: Open BAdI Definition in Transaction SE18 #
- Launch transaction
SE18. - Select the radio button Enhancement Spot and enter:
BCS_SEND_ADDRESSES. - Click Display.
- In the component tree, expand BAdI Definitions →
BCS_SEND_ADDRESSES. - Note that the BAdI is defined as Single-Use (ensure no other conflicting implementation is active in the landscape).
Step 2: Create BAdI Implementation #
- Right-click on Implementations under
BCS_SEND_ADDRESSESand choose Create BAdI Implementation (or use transactionSE19). - Specify the Enhancement Implementation Name:
- Name:
ZENH_BCS_SEND_ADDRESSES - Short Text: Enforce Fixed Sender Address for Microsoft 365 Relay
- Name:
- Specify the BAdI Implementation Details:
- BAdI Implementation Name:
ZBADI_BCS_SEND_ADDRESSES - Implementing Class:
ZCL_BCS_SEND_ADDRESSES
- BAdI Implementation Name:
- Assign the objects to your corporate transport package and transport request.
Step 3: Implement Method IF_BCS_BADI_SEND_ADDRESSES~PROCESS_ADDRESSES
#
Double-click on the Implementing Class ZCL_BCS_SEND_ADDRESSES, open method IF_BCS_BADI_SEND_ADDRESSES~PROCESS_ADDRESSES, and paste the production-tested ABAP code:
METHOD if_bcs_badi_send_addresses~process_addresses.
* ======================================================================
* Purpose: Enforce Uniform Sender for Microsoft 365 / Cloud SMTP Relay
* Reference: SAP Note 3275746 (BAdI BCS_SEND_ADDRESSES)
* Resolves: 554 5.2.252 SendAsDenied & 550 5.7.60 Client Permissions
* ======================================================================
CONSTANTS:
lc_fixed_sender TYPE bcs_address VALUE 'sap.noreply@company.com',
lc_default_name TYPE bcs_visname VALUE 'SAP System Notification',
lc_addrtype_int TYPE bcs_badi_addrtype VALUE 'INT'.
" --------------------------------------------------------------------
" 1. Enforce MIME Header From: (Displayed in Outlook / Email Client)
" --------------------------------------------------------------------
es_sender-addrtype = lc_addrtype_int.
es_sender-address = lc_fixed_sender.
" Preserve the original initiator's display name if available
" Example: "John Doe <sap.noreply@company.com>"
IF is_sender-visname IS NOT INITIAL.
es_sender-visname = is_sender-visname.
ELSE.
es_sender-visname = lc_default_name.
ENDIF.
" --------------------------------------------------------------------
" 2. Enforce SMTP Envelope MAIL FROM: (Evaluated by Microsoft 365 Relay)
" MANDATORY: Must be type 'INT' for CL_BCS_BADI_ADDRESSES=>SET_STATUS_RECIPIENT
" --------------------------------------------------------------------
es_status_recipient-addrtype = lc_addrtype_int.
es_status_recipient-address = lc_fixed_sender.
es_status_recipient-visname = es_sender-visname.
ENDMETHOD.
[!TIP]
Preserving Initiator Identity withis_sender-visname:
By copyingis_sender-visnameintoes_sender-visname, external recipients still see the human name or job title of the sender (e.g.,John Doe <sap.noreply@company.com>orBilling Department <sap.noreply@company.com>), providing clarity while ensuring the actual email address is 100% compliant with Microsoft 365 authentication.
Step 4: Activate Objects #
- Click Check (
Ctrl + F2) to verify syntax. - Click Activate (
Ctrl + F3) to activate both classZCL_BCS_SEND_ADDRESSESand enhancement implementationZENH_BCS_SEND_ADDRESSES. - Verify that the implementation runtime status shows "Implementation is active".
5. Verification & Diagnostics #
Step 5.1: Test Outbound Message in SBWP #
- Open transaction
SBWP(SAP Business Workplace). - Click New message (
Shift + F4). - Enter title: Testing Fixed Sender for Microsoft 365.
- Enter an external recipient address.
- Send the email.
Step 5.2: Inspect Outbound Queue in Transaction SOST #
- Launch transaction
SOST. - Locate the transmission record.
- Verify the Sender field: It must display
sap.noreply@company.com(with the initiator's display name). - Trigger transmission: The email should transition to status Transmitted (Green) without error 554 or 550.
Step 5.3: Verify via SAPconnect Internal Trace (SCOT) #
As recommended by SAP Note 3275746, verify that the trace explicitly captures the BAdI override:
- Open transaction
SCOT. - Navigate to:
Utilities -> Trace -> Internal Trace. - Review the trace log for the message ID. The log will confirm:
========================================================================
SAPconnect Trace: BAdI BCS_SEND_ADDRESSES
========================================================================
Original Sender (IS_SENDER) : JDOE (john.doe@company.com)
Original Status Recipient : JDOE (john.doe@company.com)
-> Calling BAdI Implementation : ZCL_BCS_SEND_ADDRESSES
-> Updated Sender (ES_SENDER) : sap.noreply@company.com [INT]
-> Updated Status Recipient : sap.noreply@company.com [INT]
========================================================================
Step 5.4: Inspect Raw Message Headers at Recipient #
Open the received email and examine internet headers:
From: "John Doe" <sap.noreply@company.com>
To: client.recipient@customer.com
Return-Path: <sap.noreply@company.com>
Authentication-Results: spf=pass (sender IP authorized) smtp.mailfrom=sap.noreply@company.com; dkim=pass
Both From and the envelope Return-Path reflect the certified corporate mailbox, completely resolving Microsoft 365 relay restrictions.
6. Key Gotchas & Implementation Checklist #
| Checkpoint | Potential Pitfall | Resolution / Best Practice |
|---|---|---|
ADDRTYPE = 'INT' Missing |
Leaving addrtype blank causes CL_BCS_BADI_ADDRESSES=>SET_STATUS_RECIPIENT to ignore the envelope change. |
Always assign es_status_recipient-addrtype = 'INT' and es_sender-addrtype = 'INT'. |
| Single-Use BAdI Conflict | Another custom implementation of BCS_SEND_ADDRESSES is already active in the client. |
Deactivate or consolidate into ZENH_BCS_SEND_ADDRESSES (only 1 active implementation allowed). |
| Microsoft 365 SendAsDenied | Only ES_SENDER was set, while ES_STATUS_RECIPIENT remained user email. |
Assign es_status_recipient-address = lc_fixed_sender. |
| User Recognition | Recipients don't know who triggered the invoice or purchase order. | Copy is_sender-visname to es_sender-visname so human names appear in the email client. |
| SCOT Default Domain | Changing default domain in SCOT does not override existing SU01 emails. |
BAdI BCS_SEND_ADDRESSES is the only global override mechanism supported by SAP. |