Configuring a Uniform Default Sender Email Address in SAP S/4HANA & NetWeaver via BAdI BCS_SEND_ADDRESSES (SAP Note 3275746)

Step-by-step implementation guide for overriding and enforcing a uniform default sender email address across all outbound SAPconnect emails using Single-Use BAdI BCS_SEND_ADDRESSES (Interface IF_BCS_BADI_SEND_ADDRESSES) per SAP Note 3275746. Details the critical ES_STATUS_RECIPIENT & ADDRTYPE=INT requirement to eliminate Microsoft 365 Exchange Online 554 5.2.252 SendAsDenied errors while preserving human sender display names.

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 if sap.noreply@company.com has explicit "Send As" or "Send on Behalf" permissions for jdoe@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:

  1. ES_SENDER: Controls the MIME Header From: displayed to the human recipient in their email client (Outlook, Gmail).
  2. ES_STATUS_RECIPIENT: Controls the SMTP Envelope MAIL FROM: passed during the low-level SMTP protocol handshake.

[!CAUTION]
The Common Implementation Trap with Microsoft 365:
Many developers only populate ES_SENDER and leave ES_STATUS_RECIPIENT empty.

If you only update ES_SENDER, the SMTP protocol command MAIL FROM:<...> still uses the original user's email address! Microsoft 365 evaluates MAIL FROM: for mailbox authorization, resulting in the exact same 554 5.2.252 SendAsDenied termination.

MANDATORY RULES:

  1. You MUST assign both ES_SENDER and ES_STATUS_RECIPIENT to your authenticated corporate relay address (e.g. sap.noreply@company.com).
  2. You MUST explicitly set ADDRTYPE = 'INT'. If ADDRTYPE is not 'INT', SAP's internal handler CL_BCS_BADI_ADDRESSES=>SET_STATUS_RECIPIENT will bypass updating the envelope address.

4. Step-by-Step Implementation Guide (SE18 / SE19) #

Step 1: Open BAdI Definition in Transaction SE18 #

  1. Launch transaction SE18.
  2. Select the radio button Enhancement Spot and enter: BCS_SEND_ADDRESSES.
  3. Click Display.
  4. In the component tree, expand BAdI Definitions → BCS_SEND_ADDRESSES.
  5. Note that the BAdI is defined as Single-Use (ensure no other conflicting implementation is active in the landscape).

Step 2: Create BAdI Implementation #

  1. Right-click on Implementations under BCS_SEND_ADDRESSES and choose Create BAdI Implementation (or use transaction SE19).
  2. Specify the Enhancement Implementation Name:
    • Name: ZENH_BCS_SEND_ADDRESSES
    • Short Text: Enforce Fixed Sender Address for Microsoft 365 Relay
  3. Specify the BAdI Implementation Details:
    • BAdI Implementation Name: ZBADI_BCS_SEND_ADDRESSES
    • Implementing Class: ZCL_BCS_SEND_ADDRESSES
  4. 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 with is_sender-visname:
By copying is_sender-visname into es_sender-visname, external recipients still see the human name or job title of the sender (e.g., John Doe <sap.noreply@company.com> or Billing Department <sap.noreply@company.com>), providing clarity while ensuring the actual email address is 100% compliant with Microsoft 365 authentication.

Step 4: Activate Objects #

  1. Click Check (Ctrl + F2) to verify syntax.
  2. Click Activate (Ctrl + F3) to activate both class ZCL_BCS_SEND_ADDRESSES and enhancement implementation ZENH_BCS_SEND_ADDRESSES.
  3. Verify that the implementation runtime status shows "Implementation is active".

5. Verification & Diagnostics #

Step 5.1: Test Outbound Message in SBWP #

  1. Open transaction SBWP (SAP Business Workplace).
  2. Click New message (Shift + F4).
  3. Enter title: Testing Fixed Sender for Microsoft 365.
  4. Enter an external recipient address.
  5. Send the email.

Step 5.2: Inspect Outbound Queue in Transaction SOST #

  1. Launch transaction SOST.
  2. Locate the transmission record.
  3. Verify the Sender field: It must display sap.noreply@company.com (with the initiator's display name).
  4. 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:

  1. Open transaction SCOT.
  2. Navigate to: Utilities -> Trace -> Internal Trace.
  3. 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.

Related notes in Batch Jobs & Spool