Fossil SCM
Improvements to formatting in generated emails to make them appear less like spam. Suggestions from "gahr" on the forum.
Commit
27404ad05f378c180e87a146d7054032e709dd1e4396252b4d54587dcff177fe
Parent
164c3d1a6a16ff2…
1 file changed
+23
-5
+23
-5
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -619,10 +619,24 @@ | ||
| 619 | 619 | if( nDot==0 ) return 0; /* No "." in the domain */ |
| 620 | 620 | |
| 621 | 621 | /* If we reach this point, the email address is valid */ |
| 622 | 622 | return mprintf("%.*s", i, z); |
| 623 | 623 | } |
| 624 | + | |
| 625 | +/* | |
| 626 | +** Return the hostname portion of an email address - the part following | |
| 627 | +** the @ | |
| 628 | +*/ | |
| 629 | +char *email_hostname(const char *zAddr){ | |
| 630 | + char *z = strchr(zAddr, '@'); | |
| 631 | + if( z ){ | |
| 632 | + z++; | |
| 633 | + }else{ | |
| 634 | + z = (char*)zAddr; | |
| 635 | + } | |
| 636 | + return z; | |
| 637 | +} | |
| 624 | 638 | |
| 625 | 639 | /* |
| 626 | 640 | ** Extract all To: header values from the email header supplied. |
| 627 | 641 | ** Store them in the array list. |
| 628 | 642 | */ |
| @@ -668,10 +682,11 @@ | ||
| 668 | 682 | ** From: |
| 669 | 683 | ** Date: |
| 670 | 684 | ** Message-Id: |
| 671 | 685 | ** Content-Type: |
| 672 | 686 | ** Content-Transfer-Encoding: |
| 687 | +** MIME-Version: | |
| 673 | 688 | ** |
| 674 | 689 | ** The caller maintains ownership of the input Blobs. This routine will |
| 675 | 690 | ** read the Blobs and send them onward to the email system, but it will |
| 676 | 691 | ** not free them. |
| 677 | 692 | */ |
| @@ -700,14 +715,16 @@ | ||
| 700 | 715 | /* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is |
| 701 | 716 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 702 | 717 | ** and $(from) is the sender. */ |
| 703 | 718 | sqlite3_randomness(sizeof(r1), &r1); |
| 704 | 719 | r2 = time(0); |
| 705 | - blob_appendf(pOut, "Message-Id: <%llxx%016llx.%s>\r\n", r2, r1, p->zFrom); | |
| 720 | + blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n", | |
| 721 | + r2, r1, email_hostname(p->zFrom)); | |
| 706 | 722 | } |
| 707 | 723 | blob_add_final_newline(pBody); |
| 708 | - blob_appendf(pOut,"Content-Type: text/plain\r\n"); | |
| 724 | + blob_appendf(pOut, "MIME-Version: 1.0\r\n"); | |
| 725 | + blob_appendf(pOut, "Content-Type: text/plain; charset=\"UTF-8\"\r\n"); | |
| 709 | 726 | #if 0 |
| 710 | 727 | blob_appendf(pOut, "Content-Transfer-Encoding: base64\r\n\r\n"); |
| 711 | 728 | append_base64(pOut, pBody); |
| 712 | 729 | #else |
| 713 | 730 | blob_appendf(pOut, "Content-Transfer-Encoding: quoted-printable\r\n\r\n"); |
| @@ -1951,14 +1968,16 @@ | ||
| 1951 | 1968 | if( p->needMod ){ |
| 1952 | 1969 | blob_appendf(&p->hdr, "Subject: %s Pending Moderation: %s\r\n", |
| 1953 | 1970 | zSub, zTitle); |
| 1954 | 1971 | }else{ |
| 1955 | 1972 | blob_appendf(&p->hdr, "Subject: %s %s\r\n", zSub, zTitle); |
| 1956 | - blob_appendf(&p->hdr, "Message-Id: <%s.%s>\r\n", zUuid, zFrom); | |
| 1973 | + blob_appendf(&p->hdr, "Message-Id: <%.32s@%s>\r\n", | |
| 1974 | + zUuid, email_hostname(zFrom)); | |
| 1957 | 1975 | zIrt = db_column_text(&q, 4); |
| 1958 | 1976 | if( zIrt && zIrt[0] ){ |
| 1959 | - blob_appendf(&p->hdr, "In-Reply-To: <%s.%s>\r\n", zIrt, zFrom); | |
| 1977 | + blob_appendf(&p->hdr, "In-Reply-To: <%.32s@%s>\r\n", | |
| 1978 | + zIrt, email_hostname(zFrom)); | |
| 1960 | 1979 | } |
| 1961 | 1980 | } |
| 1962 | 1981 | blob_init(&p->txt, 0, 0); |
| 1963 | 1982 | if( p->needMod ){ |
| 1964 | 1983 | blob_appendf(&p->txt, |
| @@ -2335,11 +2354,10 @@ | ||
| 2335 | 2354 | db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;"); |
| 2336 | 2355 | |
| 2337 | 2356 | send_alerts_done: |
| 2338 | 2357 | email_sender_free(pSender); |
| 2339 | 2358 | if( g.fSqlTrace ) fossil_trace("-- END email_send_alerts(%u)\n", flags); |
| 2340 | - db_end_transaction(0); | |
| 2341 | 2359 | } |
| 2342 | 2360 | |
| 2343 | 2361 | /* |
| 2344 | 2362 | ** Do backoffice processing for email notifications. In other words, |
| 2345 | 2363 | ** check to see if any email notifications need to occur, and then |
| 2346 | 2364 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -619,10 +619,24 @@ | |
| 619 | if( nDot==0 ) return 0; /* No "." in the domain */ |
| 620 | |
| 621 | /* If we reach this point, the email address is valid */ |
| 622 | return mprintf("%.*s", i, z); |
| 623 | } |
| 624 | |
| 625 | /* |
| 626 | ** Extract all To: header values from the email header supplied. |
| 627 | ** Store them in the array list. |
| 628 | */ |
| @@ -668,10 +682,11 @@ | |
| 668 | ** From: |
| 669 | ** Date: |
| 670 | ** Message-Id: |
| 671 | ** Content-Type: |
| 672 | ** Content-Transfer-Encoding: |
| 673 | ** |
| 674 | ** The caller maintains ownership of the input Blobs. This routine will |
| 675 | ** read the Blobs and send them onward to the email system, but it will |
| 676 | ** not free them. |
| 677 | */ |
| @@ -700,14 +715,16 @@ | |
| 700 | /* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is |
| 701 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 702 | ** and $(from) is the sender. */ |
| 703 | sqlite3_randomness(sizeof(r1), &r1); |
| 704 | r2 = time(0); |
| 705 | blob_appendf(pOut, "Message-Id: <%llxx%016llx.%s>\r\n", r2, r1, p->zFrom); |
| 706 | } |
| 707 | blob_add_final_newline(pBody); |
| 708 | blob_appendf(pOut,"Content-Type: text/plain\r\n"); |
| 709 | #if 0 |
| 710 | blob_appendf(pOut, "Content-Transfer-Encoding: base64\r\n\r\n"); |
| 711 | append_base64(pOut, pBody); |
| 712 | #else |
| 713 | blob_appendf(pOut, "Content-Transfer-Encoding: quoted-printable\r\n\r\n"); |
| @@ -1951,14 +1968,16 @@ | |
| 1951 | if( p->needMod ){ |
| 1952 | blob_appendf(&p->hdr, "Subject: %s Pending Moderation: %s\r\n", |
| 1953 | zSub, zTitle); |
| 1954 | }else{ |
| 1955 | blob_appendf(&p->hdr, "Subject: %s %s\r\n", zSub, zTitle); |
| 1956 | blob_appendf(&p->hdr, "Message-Id: <%s.%s>\r\n", zUuid, zFrom); |
| 1957 | zIrt = db_column_text(&q, 4); |
| 1958 | if( zIrt && zIrt[0] ){ |
| 1959 | blob_appendf(&p->hdr, "In-Reply-To: <%s.%s>\r\n", zIrt, zFrom); |
| 1960 | } |
| 1961 | } |
| 1962 | blob_init(&p->txt, 0, 0); |
| 1963 | if( p->needMod ){ |
| 1964 | blob_appendf(&p->txt, |
| @@ -2335,11 +2354,10 @@ | |
| 2335 | db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;"); |
| 2336 | |
| 2337 | send_alerts_done: |
| 2338 | email_sender_free(pSender); |
| 2339 | if( g.fSqlTrace ) fossil_trace("-- END email_send_alerts(%u)\n", flags); |
| 2340 | db_end_transaction(0); |
| 2341 | } |
| 2342 | |
| 2343 | /* |
| 2344 | ** Do backoffice processing for email notifications. In other words, |
| 2345 | ** check to see if any email notifications need to occur, and then |
| 2346 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -619,10 +619,24 @@ | |
| 619 | if( nDot==0 ) return 0; /* No "." in the domain */ |
| 620 | |
| 621 | /* If we reach this point, the email address is valid */ |
| 622 | return mprintf("%.*s", i, z); |
| 623 | } |
| 624 | |
| 625 | /* |
| 626 | ** Return the hostname portion of an email address - the part following |
| 627 | ** the @ |
| 628 | */ |
| 629 | char *email_hostname(const char *zAddr){ |
| 630 | char *z = strchr(zAddr, '@'); |
| 631 | if( z ){ |
| 632 | z++; |
| 633 | }else{ |
| 634 | z = (char*)zAddr; |
| 635 | } |
| 636 | return z; |
| 637 | } |
| 638 | |
| 639 | /* |
| 640 | ** Extract all To: header values from the email header supplied. |
| 641 | ** Store them in the array list. |
| 642 | */ |
| @@ -668,10 +682,11 @@ | |
| 682 | ** From: |
| 683 | ** Date: |
| 684 | ** Message-Id: |
| 685 | ** Content-Type: |
| 686 | ** Content-Transfer-Encoding: |
| 687 | ** MIME-Version: |
| 688 | ** |
| 689 | ** The caller maintains ownership of the input Blobs. This routine will |
| 690 | ** read the Blobs and send them onward to the email system, but it will |
| 691 | ** not free them. |
| 692 | */ |
| @@ -700,14 +715,16 @@ | |
| 715 | /* Message-id format: "<$(date)x$(random).$(from)>" where $(date) is |
| 716 | ** the current unix-time in hex, $(random) is a 64-bit random number, |
| 717 | ** and $(from) is the sender. */ |
| 718 | sqlite3_randomness(sizeof(r1), &r1); |
| 719 | r2 = time(0); |
| 720 | blob_appendf(pOut, "Message-Id: <%llxx%016llx@%s>\r\n", |
| 721 | r2, r1, email_hostname(p->zFrom)); |
| 722 | } |
| 723 | blob_add_final_newline(pBody); |
| 724 | blob_appendf(pOut, "MIME-Version: 1.0\r\n"); |
| 725 | blob_appendf(pOut, "Content-Type: text/plain; charset=\"UTF-8\"\r\n"); |
| 726 | #if 0 |
| 727 | blob_appendf(pOut, "Content-Transfer-Encoding: base64\r\n\r\n"); |
| 728 | append_base64(pOut, pBody); |
| 729 | #else |
| 730 | blob_appendf(pOut, "Content-Transfer-Encoding: quoted-printable\r\n\r\n"); |
| @@ -1951,14 +1968,16 @@ | |
| 1968 | if( p->needMod ){ |
| 1969 | blob_appendf(&p->hdr, "Subject: %s Pending Moderation: %s\r\n", |
| 1970 | zSub, zTitle); |
| 1971 | }else{ |
| 1972 | blob_appendf(&p->hdr, "Subject: %s %s\r\n", zSub, zTitle); |
| 1973 | blob_appendf(&p->hdr, "Message-Id: <%.32s@%s>\r\n", |
| 1974 | zUuid, email_hostname(zFrom)); |
| 1975 | zIrt = db_column_text(&q, 4); |
| 1976 | if( zIrt && zIrt[0] ){ |
| 1977 | blob_appendf(&p->hdr, "In-Reply-To: <%.32s@%s>\r\n", |
| 1978 | zIrt, email_hostname(zFrom)); |
| 1979 | } |
| 1980 | } |
| 1981 | blob_init(&p->txt, 0, 0); |
| 1982 | if( p->needMod ){ |
| 1983 | blob_appendf(&p->txt, |
| @@ -2335,11 +2354,10 @@ | |
| 2354 | db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;"); |
| 2355 | |
| 2356 | send_alerts_done: |
| 2357 | email_sender_free(pSender); |
| 2358 | if( g.fSqlTrace ) fossil_trace("-- END email_send_alerts(%u)\n", flags); |
| 2359 | } |
| 2360 | |
| 2361 | /* |
| 2362 | ** Do backoffice processing for email notifications. In other words, |
| 2363 | ** check to see if any email notifications need to occur, and then |
| 2364 |