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.

drh 2018-08-16 19:51 trunk
Commit 731836b8698a2ab178d2d29aa28b52c382fef076a524c4bae1bfbe61c41a2d6b
1 file changed +12 -7
+12 -7
--- src/email.c
+++ src/email.c
@@ -756,27 +756,32 @@
756756
** "In-Reply-To:".
757757
**
758758
** This routine will add fields to the header as follows:
759759
**
760760
** From:
761
-** Return-Path:
762761
** Date:
763762
** Message-Id:
764763
** Content-Type:
765764
** Content-Transfer-Encoding:
766765
** MIME-Version:
766
+** X-Fossil-From:
767767
**
768768
** The caller maintains ownership of the input Blobs. This routine will
769769
** read the Blobs and send them onward to the email system, but it will
770770
** not free them.
771
+**
772
+** The Message-Id: field is added if there is not already a Message-Id
773
+** in the pHdr parameter.
771774
**
772775
** If the zFromName argument is not NULL, then it should be a human-readable
773776
** name or handle for the sender. In that case, "From:" becomes a made-up
774777
** 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.
778783
*/
779784
void email_send(
780785
EmailSender *p, /* Emailer context */
781786
Blob *pHdr, /* Email header (incomplete) */
782787
Blob *pBody, /* Email body */
@@ -801,19 +806,19 @@
801806
}
802807
blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr));
803808
if( zFromName ){
804809
blob_appendf(pOut, "From: %s <%s@%s>\r\n",
805810
zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom));
811
+ blob_appendf(pOut, "X-Fossil-From: <%s>\r\n", p->zFrom);
806812
}else{
807813
blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
808814
}
809
- blob_appendf(pOut, "Return-Path: <%s>\r\n", p->zFrom);
810815
blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
811816
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
813818
** 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. */
815820
sqlite3_randomness(sizeof(r1), &r1);
816821
r2 = time(0);
817822
blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n",
818823
r2, r1, email_hostname(p->zFrom));
819824
}
820825
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button