Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improvements to formatting in generated emails to make them appear less like spam. Suggestions from "gahr" on the forum. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
27404ad05f378c180e87a146d7054032 |
User & Date: | drh 2018-08-09 15:39:47 |
Context
2018-08-09
| ||
16:00 | Fix an unfinalized prepared statement in the "fossil bisect ui" command. ... (check-in: 148d4b66 user: drh tags: trunk) | |
15:39 | Improvements to formatting in generated emails to make them appear less like spam. Suggestions from "gahr" on the forum. ... (check-in: 27404ad0 user: drh tags: trunk) | |
14:15 | Take care that a bug in the email alert sender results in missed alerts rather than an endless cascade of duplicate alerts. ... (check-in: 164c3d1a user: drh tags: trunk) | |
Changes
Changes to src/email.c.
︙ | ︙ | |||
617 618 619 620 621 622 623 624 625 626 627 628 629 630 | 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); } /* ** 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; | > > > > > > > > > > > > > > | 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 | ** This routine will add fields to the header as follows: ** ** From: ** Date: ** Message-Id: ** Content-Type: ** Content-Transfer-Encoding: ** ** 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; | > | 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 | 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); | | > > | | 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, 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; 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 | 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); | | > | > | 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: <%.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: <%.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 | ** 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); | < | 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); } /* ** Do backoffice processing for email notifications. In other words, ** check to see if any email notifications need to occur, and then ** do them. ** |
︙ | ︙ |