1 /* $NetBSD: smtputf8.h,v 1.3 2020/03/18 19:05:16 christos Exp $ */ 2 3 #ifndef _SMTPUTF8_H_INCLUDED_ 4 #define _SMTPUTF8_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* smtputf8 3h 9 /* SUMMARY 10 /* SMTPUTF8 support 11 /* SYNOPSIS 12 /* #include <smtputf8.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * Avoiding chicken-and-egg problems during the initial SMTPUTF8 roll-out in 18 * environments with pre-existing mail flows that contain UTF8. 19 * 20 * Prior to SMTPUTF8, mail flows that contain UTF8 worked because the vast 21 * majority of MTAs is perfectly capable of handling UTF8 in address 22 * localparts (and in headers), even if pre-SMTPUTF8 standards do not 23 * support this practice. 24 * 25 * When turning on Postfix SMTPUTF8 support for the first time, we don't want 26 * to suddenly break pre-existing mail flows that contain UTF8 because 1) a 27 * client does not request SMTPUTF8 support, and because 2) a down-stream 28 * MTA does not announce SMTPUTF8 support. 29 * 30 * While 1) is easy enough to avoid (keep accepting UTF8 in address localparts 31 * just like Postfix has always done), 2) presents a thornier problem. The 32 * root cause of that problem is the need for SMTPUTF8 autodetection. 33 * 34 * What is SMTPUTF8 autodetection? Postfix cannot rely solely on the sender's 35 * declaration that a message requires SMTPUTF8 support, because UTF8 may be 36 * introduced during local processing (for example, the client hostname in 37 * Postfix's Received: header, adding @$myorigin or .$mydomain to an 38 * incomplete address, address rewriting, alias expansion, automatic BCC 39 * recipients, local forwarding, and changes made by header checks or Milter 40 * applications). 41 * 42 * In summary, after local processing has happened, Postfix may decide that a 43 * message requires SMTPUTF8 support, even when that message initially did 44 * not require SMTPUTF8 support. This could make the message undeliverable 45 * to destinations that do not support SMTPUTF8. In an environment with 46 * pre-existing mail flows that contain UTF8, we want to avoid disrupting 47 * those mail flows when rolling out SMTPUTF8 support. 48 * 49 * For the vast majority of sites, the simplest solution is to autodetect 50 * SMTPUTF8 support only for Postfix sendmail command-line submissions, at 51 * least as long as SMTPUTF8 support has not yet achieved wold domination. 52 * 53 * However, sites that add UTF8 content via local processing (see above) should 54 * autodetect SMTPUTF8 support for all email. 55 * 56 * smtputf8_autodetect() uses the setting of the smtputf8_autodetect_classes 57 * parameter, and the mail source classes defined in mail_params.h. 58 */ 59 extern int smtputf8_autodetect(int); 60 61 /* 62 * The flag SMTPUTF8_FLAG_REQUESTED is raised on request by the sender, or 63 * when a queue file contains at least one UTF8 envelope recipient. One this 64 * flag is raised it is preserved when mail is forwarded or bounced. 65 * 66 * The flag SMTPUTF8_FLAG_HEADER is raised when a queue file contains at least 67 * one UTF8 message header. 68 * 69 * The flag SMTPUTF8_FLAG_SENDER is raised when a queue file contains an UTF8 70 * envelope sender. 71 * 72 * The three flags SMTPUTF8_FLAG_REQUESTED/HEADER/SENDER are stored in the 73 * queue file, are sent with delivery requests to Postfix delivery agents, 74 * and are sent with "flush" requests to the bounce daemon to ensure that 75 * the resulting notification message will have a content-transfer-encoding 76 * of 8bit. 77 * 78 * In the future, mailing lists will have a mix of UTF8 and non-UTF8 79 * subscribers. With the following flag, Postfix can avoid requiring 80 * SMTPUTF8 delivery when it isn't really needed. 81 * 82 * The flag SMTPUTF8_FLAG_RECIPIENT is raised when a delivery request (NOT: 83 * message) contains at least one UTF8 envelope recipient. The flag is NOT 84 * stored in the queue file. The flag sent in requests to the bounce daemon 85 * ONLY when bouncing a single recipient. The flag is used ONLY in requests 86 * to Postfix delivery agents, to give Postfix flexibility when delivering 87 * messages to non-SMTPUTF8 servers. 88 * 89 * If a delivery request has none of the flags SMTPUTF8_FLAG_RECIPIENT, 90 * SMTPUTF8_FLAG_SENDER, or SMTPUTF8_FLAG_HEADER, then the message can 91 * safely be delivered to a non-SMTPUTF8 server (DSN original recipients 92 * will be encoded appropriately per RFC 6533). 93 * 94 * To allow even more SMTPUTF8 mail to be sent to non-SMTPUTF8 servers, 95 * implement RFC 2047 header encoding in the Postfix SMTP client, and update 96 * the SMTP client protocol engine. 97 */ 98 #define SMTPUTF8_FLAG_NONE (0) 99 #define SMTPUTF8_FLAG_REQUESTED (1<<0) /* queue file/delivery/bounce request */ 100 #define SMTPUTF8_FLAG_HEADER (1<<1) /* queue file/delivery/bounce request */ 101 #define SMTPUTF8_FLAG_SENDER (1<<2) /* queue file/delivery/bounce request */ 102 #define SMTPUTF8_FLAG_RECIPIENT (1<<3) /* delivery request only */ 103 104 /* LICENSE 105 /* .ad 106 /* .fi 107 /* The Secure Mailer license must be distributed with this software. 108 /* AUTHOR(S) 109 /* Wietse Venema 110 /* IBM T.J. Watson Research 111 /* P.O. Box 704 112 /* Yorktown Heights, NY 10598, USA 113 /*--*/ 114 115 #endif 116