2021 Jun 10 7:05 AM
In our company we have two SMTP servers configured for sending mails. One server for sending mails within the company and the other one for sending external mails. We have configured two SMTP nodes SMTP1 and SMTP2 in tcode SCOT. All internal mails send from sap should route through SMTP1 and external mail through SMTP2. This means all mails sending with in the company should be send from the SMTP server configured in the SMTP1 and external mails should send from SMTP server configured in SMTP2.
In ABAP, we use CL_BCS classes for sending mail. But, in any of the BCS classes methods we used, we cannot find an area where we can mention the SMTP node to be used for sending mail. If somebody knows, please help.
2021 Jun 11 4:14 PM
2021 Jun 10 7:42 AM
Hi!
Based on what you describe, I would not try to do that in code at all.
Instead, this should be system config in SCOT. On the nodes, there are settings for address types, which has settings for address area. That's where the filtering should be done. Talk to your Basis people... 🙂
2021 Jun 10 7:57 AM
I follow jorgen_lindqvist41 (as always), this is SCOT customizing, not code. Otherwise you will have to use real good coding to not have dependencies on the SMTP node name ..
2021 Jun 10 7:59 AM
Thank for the reply.
But I think the mentioned address area is for filtering recipient address only. For example, if I want to use the node SMTP1 to send mails to @gmail.com ids only, I can give that filter in the address area of SMTP1.
But my requirement is to filter the SMTP server (Outgoing mail server) to be used for sending the mail. I want to specify the SMTP server to be used when sending the mail.
2021 Jun 10 12:43 PM
2021 Jun 10 1:56 PM
nop, SCOT filter the outgoing email never the incoming email.
If you want to filter incoming email you have to customize the STMP server
2021 Jun 11 1:13 PM
frdric.girod
My problem in related to outgoing emails and not incoming emails. I want to programmatically (conditionally) switch between SMTP servers while sending mail. Certain set of mails with a specific from address (sender address) I want to send through one SMTP node. Another set of mails with a another sender address I want to send through the other SMTP node. Now I can do it manually by taking tcode SCOT and put * in address area of the required SMTP node every time I send a mail.
2021 Jun 11 2:50 PM
I have checked little bit, and I think it could not be possible directly when you create an email. The choice of the node is done when you send it : transaction SOST.
So ... you will create your ZSOST ?
or let SCOT do his job ?
2021 Jun 11 4:14 PM
2021 Jun 11 4:53 PM
Thank you raymond.giuseppi.
I tried sending mail with CL_BCS class routines and using FM SO_NEW_DOCUMENT_ATT_SEND_API1. But the FM SX_NODE_ID_DETERMINE is not triggered in both cases. So I don't find any use in enhancing it. Do I need to follow some other method for sending mail.
2021 Jun 11 6:22 PM
lijujohn Always use BCS to send emails (SO_* function modules are deprecated). For information BCS is a wrapper of the old code behind these function modules.
2021 Jun 12 3:12 AM
I use BCS only. But need a way to specify the SMTP node (outgoing server) to be used for sending each mail. Giving filter in SCOT helps only to redirect mails based on TO address. I want filter based on from address.
2021 Jun 14 12:11 PM
2021 Jun 14 2:53 PM
Thanks for the reply raymond.giuseppi
You are right. The FM is triggered when calling the program RSCONN01 which is scheduled in background. In the FM, by debugging, when I change the node_id at the last point, it is working. There is an enhancement point also. But could not find any information, precisely the sender (From) address, which is useful for redirecting the mail to different SMTPs. I want the sender email id of the mail at that point. Only basic information like To Address is available there. Any way to get other details of the mail at this point?
2021 Jun 14 3:23 PM
2021 Jun 14 7:20 PM
Thanks raymond.giuseppi
I think, assigning a CDG parameter for a set of users in SU01 and linking that CDG parameter to a particular SMTP node in SCOT will help to redirect mails from these set of users through that SMTP node. But my requirement is to redirect mails to different SMTPs based on the FROM address set in the sending mail and not the SAP Login ID. The FROM address is usually set in the sending mail using
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = sendermailid
i_address_name = sendermaildescription
RECEIVING
result = wa_sender.
CALL METHOD send_email->set_sender
EXPORTING
i_sender = wa_sender.
The sendermail and sendermaildescription that we set here will be shown in the inbox of the receiver. I want to redirect outgoing mails based on the above sendermailid. Enhancing the FM SX_NODE_ID_DETERMINE you suggested will serve the purpose. But the values of the above sendermailid of the outgoing mail is not available here. Only basic data like TO address is available here. If there is any way to get sendermailid, please share. Or I need a variable/value that can set in the CL_BCS class level which can be accessed in the FM SX_NODE_ID_DETERMINE.
2021 Jun 18 6:15 AM
Got a variable that holds id of the SENDER which seems to be unique for combination of sending address and name. Not sure whether it is reliable. Thanks raymond.giuseppi for the help.
2023 Mar 06 3:07 PM
Hi, lijujohn,
I have the same requirement, can you, please, navigate me, where did you find the information to evaluate SMTP node based on sender address?
Thanks
2023 Aug 01 4:26 AM
sender = cl_sapuser_bcs=>create( mailfrom ). "user ID from SAP
su01 set CDG
SPAN { font-family: "新宋体"; font-size: 10pt; color: #000000; background: #FFFFFF; }.L0S31 { font-style: italic; color: #808080; }.L0S52 { color: #0000FF; }.L0S55 { color: #800080; }.L0S70 { color: #808080; }
2024 May 27 7:41 AM
In SCOT, use 'Address area' for routing rules to differentiate between SMTP servers. Alternatively, enhance FM SX_NODE_ID_DETERMINE for more control over sender address-based routing using SMTPget.
2024 Jun 12 9:48 AM
To route emails via different SMTP nodes in SAP using CL_BCS:
Configure SCOT:
Use CL_BCS: