@@ -765,22 +765,19 @@ def test_other_mime_type(tmpdir):
765765 email
766766767767 """ ), encoding = "utf8" )
768-
769768 # Simple unsecure server config
770769 config_path = Path (tmpdir / "mailmerge_server.conf" )
771770 config_path .write_text (textwrap .dedent ("""\
772771 [smtp_server]
773772 host = open-smtp.example.com
774773 port = 25
775774 """ ), encoding = "utf8" )
776-
777775 # Run mailmerge
778776 runner = click .testing .CliRunner ()
779777 with tmpdir .as_cwd ():
780778 result = runner .invoke (main , [])
781779 assert not result .exception
782780 assert result .exit_code == 0
783-
784781 # Verify output
785782 stdout = copy .deepcopy (result .output )
786783 stdout = re .sub (r"Date:.+" , "Date: REDACTED" , stdout , re .MULTILINE )
@@ -820,27 +817,23 @@ def test_database_bom(tmpdir):
820817
821818 Hello {{name}}
822819 """ ), encoding = "utf8" )
823-
824820 # Copy database containing a BOM
825821 database_path = Path (tmpdir / "mailmerge_database.csv" )
826822 database_with_bom = utils .TESTDATA / "mailmerge_database_with_BOM.csv"
827823 shutil .copyfile (database_with_bom , database_path )
828-
829824 # Simple unsecure server config
830825 config_path = Path (tmpdir / "mailmerge_server.conf" )
831826 config_path .write_text (textwrap .dedent ("""\
832827 [smtp_server]
833828 host = open-smtp.example.com
834829 port = 25
835830 """ ), encoding = "utf8" )
836-
837831 # Run mailmerge
838832 runner = click .testing .CliRunner ()
839833 with tmpdir .as_cwd ():
840834 result = runner .invoke (main , ["--output-format" , "text" ])
841835 assert not result .exception
842836 assert result .exit_code == 0
843-
844837 # Verify output
845838 stdout = copy .deepcopy (result .output )
846839 stdout = re .sub (r"Date:.+" , "Date: REDACTED" , stdout , re .MULTILINE )
@@ -871,29 +864,25 @@ def test_database_tsv(tmpdir):
871864
872865 Hello {{name}}
873866 """ ), encoding = "utf8" )
874-
875867 # Tab-separated format database
876868 database_path = Path (tmpdir / "mailmerge_database.csv" )
877869 database_path .write_text (textwrap .dedent ("""\
878870 email\t name
879871880872 """ ), encoding = "utf8" )
881-
882873 # Simple unsecure server config
883874 config_path = Path (tmpdir / "mailmerge_server.conf" )
884875 config_path .write_text (textwrap .dedent ("""\
885876 [smtp_server]
886877 host = open-smtp.example.com
887878 port = 25
888879 """ ), encoding = "utf8" )
889-
890880 # Run mailmerge
891881 runner = click .testing .CliRunner ()
892882 with tmpdir .as_cwd ():
893883 result = runner .invoke (main , ["--output-format" , "text" ])
894884 assert not result .exception
895885 assert result .exit_code == 0
896-
897886 # Verify output
898887 stdout = copy .deepcopy (result .output )
899888 stdout = re .sub (r"Date:.+" , "Date: REDACTED" , stdout , re .MULTILINE )
@@ -924,29 +913,25 @@ def test_database_semicolon(tmpdir):
924913
925914 Hello {{name}}
926915 """ ), encoding = "utf8" )
927-
928916 # Semicolon-separated format database
929917 database_path = Path (tmpdir / "mailmerge_database.csv" )
930918 database_path .write_text (textwrap .dedent ("""\
931919 email;name
932920933921 """ ), encoding = "utf8" )
934-
935922 # Simple unsecure server config
936923 config_path = Path (tmpdir / "mailmerge_server.conf" )
937924 config_path .write_text (textwrap .dedent ("""\
938925 [smtp_server]
939926 host = open-smtp.example.com
940927 port = 25
941928 """ ), encoding = "utf8" )
942-
943929 # Run mailmerge
944930 runner = click .testing .CliRunner ()
945931 with tmpdir .as_cwd ():
946932 result = runner .invoke (main , ["--output-format" , "text" ])
947933 assert not result .exception
948934 assert result .exit_code == 0
949-
950935 # Verify output
951936 stdout = copy .deepcopy (result .output )
952937 stdout = re .sub (r"Date:.+" , "Date: REDACTED" , stdout , re .MULTILINE )
@@ -965,3 +950,50 @@ def test_database_semicolon(tmpdir):
965950 >>> Limit was 1 message. To remove the limit, use the --no-limit option.
966951 >>> This was a dry run. To send messages, use the --no-dry-run option.
967952 """ ) # noqa: E501
953+
954+
955+ def test_utf8smtp_trigger (tmpdir ):
956+ """Verify triggers to rcpt_options=['UTF8SMTP']."""
957+ template_path = Path (tmpdir / "mailmerge_template.txt" )
958+ template_path .write_text (textwrap .dedent ("""\
959+ 960+ 961+ SUBJECT: UTF8SMTP Test
962+ Hello{{name}}!
963+ """ ), encoding = "utf8" )
964+ database_path = Path (tmpdir / "mailmerge_database.csv" )
965+ database_path .write_text (textwrap .dedent ("""\
966+ email;name
967+ 968+ """ ), encoding = "utf8" )
969+ config_path = Path (tmpdir / "mailmerge_server.conf" )
970+ config_path .write_text (textwrap .dedent ("""\
971+ [smtp_server]
972+ host = open-smtp.example.com
973+ port = 25
974+ """ ), encoding = "utf8" )
975+ runner = click .testing .CliRunner ()
976+ with tmpdir .as_cwd ():
977+ result = runner .invoke (main , [
978+ "--dry-run" ,
979+ "--no-limit" ,
980+ "--output-format" , "text" ,
981+ ])
982+ assert result .exit_code == 0
983+ assert not result .exception
984+ stdout = result .output
985+ stdout = re .sub (r"Date:.+" , "Date: REDACTED" , stdout , re .MULTILINE )
986+ assert stdout == textwrap .dedent ("""\
987+ >>> message 1
988+ 989+ 990+ SUBJECT: UTF8SMTP Test
991+ MIME-Version: 1.0
992+ Content-Type: text/plain; charset="utf-8"
993+ Content-Transfer-Encoding: base64
994+ Date: REDACTED
995+ Hello Max Müller!
996+
997+ >>> message 1 sent
998+ >>> This was a dry run. To send messages, use the --no-dry-run option.
999+ """ ) # noqa: E501
0 commit comments