754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
** in the header. Likewise, the header must contains a "Subject:" line.
** The header might also include fields like "Message-Id:" or
** "In-Reply-To:".
**
** This routine will add fields to the header as follows:
**
** From:
** Return-Path:
** Date:
** Message-Id:
** Content-Type:
** Content-Transfer-Encoding:
** MIME-Version:
**
** The caller maintains ownership of the input Blobs. This routine will
** read the Blobs and send them onward to the email system, but it will
** not free them.
**
** If the zFromName argument is not NULL, then it should be a human-readable
** name or handle for the sender. In that case, "From:" becomes a made-up
** email address based on a hash of zFromName and the domain of email-self,
** and an additional "Reply-To:" field is inserted with the email-self
** address. If zFromName is a NULL pointer, then both "From:" and
** Return-Path: are set to the email-self value.
*/
void email_send(
EmailSender *p, /* Emailer context */
Blob *pHdr, /* Email header (incomplete) */
Blob *pBody, /* Email body */
const char *zFromName /* Optional human-readable name of sender */
){
|
<
>
>
>
>
|
>
|
|
>
|
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
|
** in the header. Likewise, the header must contains a "Subject:" line.
** The header might also include fields like "Message-Id:" or
** "In-Reply-To:".
**
** This routine will add fields to the header as follows:
**
** From:
** Date:
** Message-Id:
** Content-Type:
** Content-Transfer-Encoding:
** MIME-Version:
** X-Fossil-From:
**
** The caller maintains ownership of the input Blobs. This routine will
** read the Blobs and send them onward to the email system, but it will
** not free them.
**
** The Message-Id: field is added if there is not already a Message-Id
** in the pHdr parameter.
**
** If the zFromName argument is not NULL, then it should be a human-readable
** name or handle for the sender. In that case, "From:" becomes a made-up
** email address based on a hash of zFromName and the domain of email-self,
** and an additional "X-Fossil-From:" field is inserted with the email-self
** address. Downstream software might use the X-Fossil-From header to set
** the envelope-from address of the email. If zFromName is a NULL pointer,
** then the "From:" is set to the email-self value and X-Fossil-From is
** omitted.
*/
void email_send(
EmailSender *p, /* Emailer context */
Blob *pHdr, /* Email header (incomplete) */
Blob *pBody, /* Email body */
const char *zFromName /* Optional human-readable name of sender */
){
|
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
|
blob_init(&all, 0, 0);
pOut = &all;
}
blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr));
if( zFromName ){
blob_appendf(pOut, "From: %s <%s@%s>\r\n",
zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom));
}else{
blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
}
blob_appendf(pOut, "Return-Path: <%s>\r\n", p->zFrom);
blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){
/* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is
** the current unix-time in hex, $(random) is a 64-bit random number,
** and $(from) is the sender. */
sqlite3_randomness(sizeof(r1), &r1);
r2 = time(0);
blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n",
r2, r1, email_hostname(p->zFrom));
}
blob_add_final_newline(pBody);
blob_appendf(pOut, "MIME-Version: 1.0\r\n");
|
>
<
|
|
|
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
|
blob_init(&all, 0, 0);
pOut = &all;
}
blob_append(pOut, blob_buffer(pHdr), blob_size(pHdr));
if( zFromName ){
blob_appendf(pOut, "From: %s <%s@%s>\r\n",
zFromName, email_mailbox_name(zFromName), email_hostname(p->zFrom));
blob_appendf(pOut, "X-Fossil-From: <%s>\r\n", p->zFrom);
}else{
blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
}
blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){
/* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is
** the current unix-time in hex, $(random) is a 64-bit random number,
** and $(from) is the domain part of the email-self setting. */
sqlite3_randomness(sizeof(r1), &r1);
r2 = time(0);
blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n",
r2, r1, email_hostname(p->zFrom));
}
blob_add_final_newline(pBody);
blob_appendf(pOut, "MIME-Version: 1.0\r\n");
|