Fossil SCM
Do not put "Return-Path:" headers in notification emails to be sent. That is a violation of standards as only the receiving SMTP server should add the Return-Path header. Instead, include a custom X-Fossil-From: header that downstream software can use (if desired) to set the envelope header of the message.
Commit
731836b8698a2ab178d2d29aa28b52c382fef076a524c4bae1bfbe61c41a2d6b
Parent
475c9d11e9028f9…
1 file changed
+12
-7
+12
-7
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -756,27 +756,32 @@ | ||
| 756 | 756 | ** "In-Reply-To:". |
| 757 | 757 | ** |
| 758 | 758 | ** This routine will add fields to the header as follows: |
| 759 | 759 | ** |
| 760 | 760 | ** From: |
| 761 | -** Return-Path: | |
| 762 | 761 | ** Date: |
| 763 | 762 | ** Message-Id: |
| 764 | 763 | ** Content-Type: |
| 765 | 764 | ** Content-Transfer-Encoding: |
| 766 | 765 | ** MIME-Version: |
| 766 | +** X-Fossil-From: | |
| 767 | 767 | ** |
| 768 | 768 | ** The caller maintains ownership of the input Blobs. This routine will |
| 769 | 769 | ** read the Blobs and send them onward to the email system, but it will |
| 770 | 770 | ** not free them. |
| 771 | +** | |
| 772 | +** The Message-Id: field is added if there is not already a Message-Id | |
| 773 | +** in the pHdr parameter. | |
| 771 | 774 | ** |
| 772 | 775 | ** If the zFromName argument is not NULL, then it should be a human-readable |
| 773 | 776 | ** name or handle for the sender. In that case, "From:" becomes a made-up |
| 774 | 777 | ** email address based on a hash of zFromName and the domain of email-self, |
| 775 | -** and an additional "Reply-To:" field is inserted with the email-self | |
| 776 | -** address. If zFromName is a NULL pointer, then both "From:" and | |
| 777 | -** Return-Path: are set to the email-self value. | |
| 778 | +** and an additional "X-Fossil-From:" field is inserted with the email-self | |
| 779 | +** address. Downstream software might use the X-Fossil-From header to set | |
| 780 | +** the envelope-from address of the email. If zFromName is a NULL pointer, | |
| 781 | +** then the "From:" is set to the email-self value and X-Fossil-From is | |
| 782 | +** omitted. | |
| 778 | 783 | */ |
| 779 | 784 | void email_send( |
| 780 | 785 | EmailSender *p, /* Emailer context */ |
| 781 | 786 | Blob *pHdr, /* Email header (incomplete) */ |
| 782 | 787 | Blob *pBody, /* Email body */ |
| @@ -801,19 +806,19 @@ | ||
| 801 | 806 | } |
| 802 | 807 | blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr)); |
| 803 | 808 | if( zFromName ){ |
| 804 | 809 | blob_appendf(pOut, "From: %s <%s@%s>\r\n", |
| 805 | 810 | zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom)); |
| 811 | + blob_appendf(pOut, "X-Fossil-From: <%s>\r\n", p->zFrom); | |
| 806 | 812 | }else{ |
| 807 | 813 | blob_appendf(pOut, "From: <%s>\r\n", p->zFrom); |
| 808 | 814 | } |
| 809 | - blob_appendf(pOut, "Return-Path: <%s>\r\n", p->zFrom); | |
| 810 | 815 | blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0))); |
| 811 | 816 | if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){ |
| 812 | - /* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is | |
| 817 | + /* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is | |
| 813 | 818 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 814 | - ** and $(from) is the sender. */ | |
| 819 | + ** and $(from) is the domain part of the email-self setting. */ | |
| 815 | 820 | sqlite3_randomness(sizeof(r1), &r1); |
| 816 | 821 | r2 = time(0); |
| 817 | 822 | blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n", |
| 818 | 823 | r2, r1, email_hostname(p->zFrom)); |
| 819 | 824 | } |
| 820 | 825 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -756,27 +756,32 @@ | |
| 756 | ** "In-Reply-To:". |
| 757 | ** |
| 758 | ** This routine will add fields to the header as follows: |
| 759 | ** |
| 760 | ** From: |
| 761 | ** Return-Path: |
| 762 | ** Date: |
| 763 | ** Message-Id: |
| 764 | ** Content-Type: |
| 765 | ** Content-Transfer-Encoding: |
| 766 | ** MIME-Version: |
| 767 | ** |
| 768 | ** The caller maintains ownership of the input Blobs. This routine will |
| 769 | ** read the Blobs and send them onward to the email system, but it will |
| 770 | ** not free them. |
| 771 | ** |
| 772 | ** If the zFromName argument is not NULL, then it should be a human-readable |
| 773 | ** name or handle for the sender. In that case, "From:" becomes a made-up |
| 774 | ** email address based on a hash of zFromName and the domain of email-self, |
| 775 | ** and an additional "Reply-To:" field is inserted with the email-self |
| 776 | ** address. If zFromName is a NULL pointer, then both "From:" and |
| 777 | ** Return-Path: are set to the email-self value. |
| 778 | */ |
| 779 | void email_send( |
| 780 | EmailSender *p, /* Emailer context */ |
| 781 | Blob *pHdr, /* Email header (incomplete) */ |
| 782 | Blob *pBody, /* Email body */ |
| @@ -801,19 +806,19 @@ | |
| 801 | } |
| 802 | blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr)); |
| 803 | if( zFromName ){ |
| 804 | blob_appendf(pOut, "From: %s <%s@%s>\r\n", |
| 805 | zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom)); |
| 806 | }else{ |
| 807 | blob_appendf(pOut, "From: <%s>\r\n", p->zFrom); |
| 808 | } |
| 809 | blob_appendf(pOut, "Return-Path: <%s>\r\n", p->zFrom); |
| 810 | blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0))); |
| 811 | if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){ |
| 812 | /* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is |
| 813 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 814 | ** and $(from) is the sender. */ |
| 815 | sqlite3_randomness(sizeof(r1), &r1); |
| 816 | r2 = time(0); |
| 817 | blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n", |
| 818 | r2, r1, email_hostname(p->zFrom)); |
| 819 | } |
| 820 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -756,27 +756,32 @@ | |
| 756 | ** "In-Reply-To:". |
| 757 | ** |
| 758 | ** This routine will add fields to the header as follows: |
| 759 | ** |
| 760 | ** From: |
| 761 | ** Date: |
| 762 | ** Message-Id: |
| 763 | ** Content-Type: |
| 764 | ** Content-Transfer-Encoding: |
| 765 | ** MIME-Version: |
| 766 | ** X-Fossil-From: |
| 767 | ** |
| 768 | ** The caller maintains ownership of the input Blobs. This routine will |
| 769 | ** read the Blobs and send them onward to the email system, but it will |
| 770 | ** not free them. |
| 771 | ** |
| 772 | ** The Message-Id: field is added if there is not already a Message-Id |
| 773 | ** in the pHdr parameter. |
| 774 | ** |
| 775 | ** If the zFromName argument is not NULL, then it should be a human-readable |
| 776 | ** name or handle for the sender. In that case, "From:" becomes a made-up |
| 777 | ** email address based on a hash of zFromName and the domain of email-self, |
| 778 | ** and an additional "X-Fossil-From:" field is inserted with the email-self |
| 779 | ** address. Downstream software might use the X-Fossil-From header to set |
| 780 | ** the envelope-from address of the email. If zFromName is a NULL pointer, |
| 781 | ** then the "From:" is set to the email-self value and X-Fossil-From is |
| 782 | ** omitted. |
| 783 | */ |
| 784 | void email_send( |
| 785 | EmailSender *p, /* Emailer context */ |
| 786 | Blob *pHdr, /* Email header (incomplete) */ |
| 787 | Blob *pBody, /* Email body */ |
| @@ -801,19 +806,19 @@ | |
| 806 | } |
| 807 | blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr)); |
| 808 | if( zFromName ){ |
| 809 | blob_appendf(pOut, "From: %s <%s@%s>\r\n", |
| 810 | zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom)); |
| 811 | blob_appendf(pOut, "X-Fossil-From: <%s>\r\n", p->zFrom); |
| 812 | }else{ |
| 813 | blob_appendf(pOut, "From: <%s>\r\n", p->zFrom); |
| 814 | } |
| 815 | blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0))); |
| 816 | if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){ |
| 817 | /* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is |
| 818 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 819 | ** and $(from) is the domain part of the email-self setting. */ |
| 820 | sqlite3_randomness(sizeof(r1), &r1); |
| 821 | r2 = time(0); |
| 822 | blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n", |
| 823 | r2, r1, email_hostname(p->zFrom)); |
| 824 | } |
| 825 |