[REBOL] How to handle Return-Path
From: sf::sabufrancis::com at: 3-Dec-2003 12:11
The following is a mailing list situation that I discovered that I want to
share it with you. It had caused a lot of anguish for me before I could
Suppose someone sends email from address "a" which is collected by your
and then sent to another email address "b" and if "b" was not a proper email
then it would bounce. If we use the normal Rebol "send" command, then the
wher the bounce would be handled cannot be set by your Rebol app. Instead,
bounce would get passed all the way back to "a".
Not a very happy situation while writing a mailing list application.
>From whatever I could glean from the net, this is how bounces are handled.
Each email sent is put into an "envelope" and sent to the SMTP port. That
envelope contains a few simple commands as well as the data and headers
you had constructed.
When the "MAIL FROM: " command is inserted into the email "envelope" ,
the qmail program will silently insert the "Return-Path: " header to the
email address that "MAIL FROM: " is indicating before being sent over the
net. The "Return-Path: " address is what is used by most servers to bounce
back the email, if the email address was incorrect.
You cannot spoof that "Return-path: " header by inserting one of yours
while constructing the email header in your Rebol app. This is because the
one created by qmail would be right on top of the rest of the header
and other email servers would read that path and ignore other occurances
of "Return-path: " in the same header.
When I investigated the Rebol-SDK source (prot_send.r) I found that
Return-Path is not handled at all. The "MAIL FROM: " is always pointing to
the "From: " member of the email header object. That is not correct.
This is the patch that did the trick:
I commented out all occurances (there are two) of the following statement :
do-send smtp-port ["MAIL FROM: <" from ">"]
and I replaced it by a call to an internal local function which has 3
sendProperFrom header-Obj smtp-port from
The function is written as follows:
sendProperFrom: func [hObj s-port frm ]
either get in hObj 'Return-Path
[ do-send s-port ["MAIL FROM: <" hObj/Return-Path ">"]
[ do-send s-port ["MAIL FROM: <"from ">"] ]
Note that the above is a local function within the "send" func.
After the above patch, the send function works properly. Whenever
I want to give a separate "Return-Path" which is different from the "From: "
address, then I would specify that as the value of a email header
member "Return-Path: "
At the same time, when such an email is received at the other end, the
email client will be indicating that it orginated from the "From: " address
I hope this is of use. I have tested this only using qmail.
Maybe Ingo Hohmann can integrate this patch into the patched "send"
function he is developing.
If there are any other caveats I should watch out, then please do let me