| ︙ | | |
617
618
619
620
621
622
623
624
625
626
627
628
629
630
|
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if( c!=cTerm ) return 0; /* Missing terminator */
if( nAt==0 ) return 0; /* No "@" found anywhere */
if( nDot==0 ) return 0; /* No "." in the domain */
/* If we reach this point, the email address is valid */
return mprintf("%.*s", i, z);
}
/*
** Return the hostname portion of an email address - the part following
** the @
*/
char *email_hostname(const char *zAddr){
char *z = strchr(zAddr, '@');
if( z ){
z++;
}else{
z = (char*)zAddr;
}
return z;
}
/*
** Extract all To: header values from the email header supplied.
** Store them in the array list.
*/
void email_header_to(Blob *pMsg, int *pnTo, char ***pazTo){
int nTo = 0;
|
| ︙ | | |
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
+
|
** This routine will add fields to the header as follows:
**
** From:
** 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.
*/
void email_send(EmailSender *p, Blob *pHdr, Blob *pBody){
Blob all, *pOut;
|
| ︙ | | |
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
|
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
|
-
+
+
+
-
+
|
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, p->zFrom);
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");
blob_appendf(pOut,"Content-Type: text/plain\r\n");
blob_appendf(pOut, "Content-Type: text/plain; charset=\"UTF-8\"\r\n");
#if 0
blob_appendf(pOut, "Content-Transfer-Encoding: base64\r\n\r\n");
append_base64(pOut, pBody);
#else
blob_appendf(pOut, "Content-Transfer-Encoding: quoted-printable\r\n\r\n");
append_quoted(pOut, pBody);
#endif
|
| ︙ | | |
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
|
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
|
-
+
+
-
+
+
|
zUuid = db_column_text(&q, 1);
zTitle = db_column_text(&q, 3);
if( p->needMod ){
blob_appendf(&p->hdr, "Subject: %s Pending Moderation: %s\r\n",
zSub, zTitle);
}else{
blob_appendf(&p->hdr, "Subject: %s %s\r\n", zSub, zTitle);
blob_appendf(&p->hdr, "Message-Id: <%s.%s>\r\n", zUuid, zFrom);
blob_appendf(&p->hdr, "Message-Id: <%.32s@%s>\r\n",
zUuid, email_hostname(zFrom));
zIrt = db_column_text(&q, 4);
if( zIrt && zIrt[0] ){
blob_appendf(&p->hdr, "In-Reply-To: <%s.%s>\r\n", zIrt, zFrom);
blob_appendf(&p->hdr, "In-Reply-To: <%.32s@%s>\r\n",
zIrt, email_hostname(zFrom));
}
}
blob_init(&p->txt, 0, 0);
if( p->needMod ){
blob_appendf(&p->txt,
"** Pending moderator approval (%s/modreq) **\n",
zUrl
|
| ︙ | | |
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
|
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
|
-
|
** alerts that have been completely sent.
*/
db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
send_alerts_done:
email_sender_free(pSender);
if( g.fSqlTrace ) fossil_trace("-- END email_send_alerts(%u)\n", flags);
db_end_transaction(0);
}
/*
** Do backoffice processing for email notifications. In other words,
** check to see if any email notifications need to occur, and then
** do them.
**
|
| ︙ | | |