From ef2be37e23501b02622aeeaa4fb529c01b673300 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 5 Jun 2024 10:54:03 +1200 Subject: [PATCH 01/10] fix absent message error --- mal.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mal.d b/mal.d index 3ffea07..0f74cf8 100644 --- a/mal.d +++ b/mal.d @@ -133,7 +133,7 @@ main(string[] args) } enforceDie(message || messageFile, - "email messsage has to be provided through -M or -m"); + "a message has to be provided with -M or -m"); enforceDie(!(message && messageFile), "flags -M and -m cannot both be supplied in one invocation"); From e9d4bbcdcafb1caa5c03323c481c5bd3492b57d7 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 5 Jun 2024 11:11:29 +1200 Subject: [PATCH 02/10] issue warning on empty subject line --- mal.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mal.d b/mal.d index 0f74cf8..43cbe68 100644 --- a/mal.d +++ b/mal.d @@ -71,10 +71,9 @@ main(string[] args) fqdn = hostName() ~ ".local"; mailHeaders = toAddrs = []; - subject = ""; useSmtps = true; authUser = message = messageFile = passPhrase = - realName = serverAddr = serverPort = null; + realName = serverAddr = serverPort = subject = null; try { import std.getopt : config; @@ -162,6 +161,10 @@ main(string[] args) warn("warning: -P not supplied, using empty passphrase"); passPhrase = ""; } + if (!subject) { + warn("warning: -S not supplied, using empty subject line"); + subject = ""; + } try { messageBuf = From 4f3fe35990feb72c3913ac43c3e66deeecc38f18 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 5 Jun 2024 11:12:10 +1200 Subject: [PATCH 03/10] set the SMTP user to the user's address Fixes: https://todo.sr.ht/~jeremy/mal/2 --- mal.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mal.d b/mal.d index 43cbe68..70e6dec 100644 --- a/mal.d +++ b/mal.d @@ -152,7 +152,8 @@ main(string[] args) addr = "<" ~ addr ~ ">"; } - authUser = authUser ? authUser : fromStatus.localPart; + /* https://todo.sr.ht/~jeremy/mal/2 */ + authUser = authUser ? authUser : fromAddr; protocol = useSmtps ? "smtps" : "smtp"; serverAddr = serverAddr ? serverAddr : fromStatus.domainPart; serverPort = serverPort ? serverPort : useSmtps ? "465" : "587"; From 3f6315e7067d1b5274be89b134fdd96f703d7f3e Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 7 Jun 2024 08:03:18 +1200 Subject: [PATCH 04/10] improve usage message --- mal.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mal.d b/mal.d index 70e6dec..a79dfd0 100644 --- a/mal.d +++ b/mal.d @@ -127,7 +127,7 @@ main(string[] args) stderr.writeln( `usage: mal [-ksV] [-a server] [-F fqdn] [-H header] [-n name] [-P passphrase] [-p port] [-S subject] [-t toaddress] - [-u username] {-M messagefile | -m message} fromaddress`); + [-u user] {-M file | -m message} fromaddress`); return 1; } From 52dab0fb91fc5417e2c61f62f9eb67b3c6f721a9 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 17 Jun 2024 07:44:22 +1200 Subject: [PATCH 05/10] mal.1: add man page Closes: https://todo.sr.ht/~jeremy/mal/1 --- mal.1 | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 mal.1 diff --git a/mal.1 b/mal.1 new file mode 100644 index 0000000..23ee565 --- /dev/null +++ b/mal.1 @@ -0,0 +1,134 @@ +.Dd $Mdocdate: June 17 2024 $ +.Dt MAL 1 +.Os +.Sh NAME +.Nm mal +.Nd send mail +.Sh SYNOPSIS +.Nm mal +.Bk -words +.Op Fl ksV +.Op Fl a Ar server +.Op Fl F Ar fqdn +.Op Fl H Ar header +.Op Fl n Ar name +.Op Fl P Ar passphrase +.Op Fl p Ar port +.Op Fl S Ar subject +.Op Fl t Ar toaddress +.Op Fl u Ar user +.No { Ns Fl M Ar file | Fl m Ar message Ns } +.Ar fromaddress +.Ek +.Sh DESCRIPTION +.Nm +sends mail to one or more recipients, +whose addresses are specified by the +.Fl t +option. +The mail is sent from the address specified by +.Ar fromaddress , +and if +.Fl t +is not given, mail will be sent back to the sender's address. +The +.Fl P +option specifies a passphrase. +.Pp +The options are as follows: +.Bl -tag -width 123456 +.It Fl a Ar server +Specify the address of the SMTP server to connect to. +By default this is the domain segment of +.Ar fromaddress . +.It Fl F Ar fqdn +Specify the FQDN to pass to the SMTP server. +By default this is set to the system's hostname with +.Dq .local +appended to the end. +.It Fl H Ar header +Add a header to the request. +This is necessary if you would like to, for instance +CC someone in your mail. +See the +.Sx EXAMPLES +section below for an example using this option. +.It Fl k +Use an insecure SMTP connection. +By default +.Nm mal +will attempt to connect with secure SMTPS, +but if your server doesn't support this you should use +.Fl k . +See also +.Fl s +for forcing a secure connection. +.It Fl M Ar file +Specify a file which contains the message's contents. +.It Fl m Ar message +Specify a message on the command line. +.It Fl n Ar name +Specify a real name to identify the sender of the mail. +.It Fl P Ar passphrase +Specify a passphrase to use to authenticate the SMTP user. +Without this option no authentication will be used. +.It Fl p Ar port +Override the SMTP server port. +By default this will be +465 for SMTPS servers +or 587 for plain SMTP servers. +See also the +.Fl k +flag. +.It Fl S Ar subject +Specify the subject line of the mail. +.It Fl s +Force a secure SMTPS connection. +This is the default and only required if you want to override +a previous +.Fl k +flag. +.It Fl t Ar toaddress +Specify a recipient for the mail. +If you would like to CC someone instead, +see the +.Fl H +option. +If this option is not given, +the mail will be sent to the sender's address. +This option can be specified multiple times +to send email to multiple recipients. +.It Fl u Ar user +Specify the SMTP user. +By default this is the sender's address. +.It Fl V +Print the version number and exit. +.El +.Sh EXAMPLES +Send an email to +.Mt joe@example.org +with the message +.Dq Hello : +.Pp +.Dl mal -m Hello -t joe@example.org -P mypasswd you@example.org +.Pp +Read the message from the file +.Dq mesg +instead: +.Pp +.Dl mal -M mesg -t joe@example.org -P mypasswd you@example.org +.Pp +CC +.Mt jane@example.org : +.Pp +.Dl mal -M mesg -t joe@example.org -H 'Cc: ' -P mypasswd you@example.org +.Pp +.Sh AUTHORS +.An Jeremy Baxter Aq Mt jeremy@baxters.nz +.Sh BUGS +.Pp +Currently known bugs or issues can be found at the tracker: +.Lk https://todo.sr.ht/~jeremy/mal +.Pp +If you happen to find a bug, +please report it to me using my address above. From 2eae8fa5ed578960d203ea8635c1079c0b88812b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 17 Jun 2024 07:51:47 +1200 Subject: [PATCH 06/10] switch to ISC License --- COPYING | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/COPYING b/COPYING index 1450581..1536dee 100644 --- a/COPYING +++ b/COPYING @@ -1,25 +1,13 @@ Copyright (c) 2024 Jeremy Baxter. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file From deb1226bfe42468326e2643b61f88c4543d4ea6c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 17 Jun 2024 07:57:49 +1200 Subject: [PATCH 07/10] install man page --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index d1504b7..5e997fa 100644 --- a/Makefile +++ b/Makefile @@ -20,5 +20,6 @@ clean: install: install -Dm755 mal "${DESTDIR}${PREFIX}"/bin/mal + install -Dm644 mal.1 "${DESTDIR}${PREFIX}"/share/man/man1/mal.1 .PHONY: all clean install From c4e68581da62c78818a19cfe7363c25e893785c3 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 17 Jun 2024 07:58:30 +1200 Subject: [PATCH 08/10] cut down README.md --- README.md | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index d8c3458..bd38d64 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,13 @@ -mal sends an email to one or more recipients, through information passed +mal sends email to one or more recipients, through information passed on its command line. Read COPYING for information on redistribution. ## compilation -Install ldc and curl, and run make. To install the binary systemwide, -run make install after compiling. +Install ldc and libcurl, and run `make`. +To install, run `make install` after compiling. -## usage +## documentation -Send an email from you@example.org to joe@example.org -with the message body "hello!": - - mal -m 'hello!' -t joe@example.org -P password123 you@example.org - -Read the message body from a file instead: - - mal -M mesgfile -t joe@example.org -P password123 you@example.org - -Send the message to multiple recipients: - - mal -M mesgfile -t joe@example.org -t jane@example.org -P password123 \ - you@example.org - -If SSL is not working properly, use an insecure connection with -k: - - mal -k -m 'hello!' -t joe@example.org -P password123 \ - you@example.org - -To send a message from an address with a plus in it, manually specify -the username with -u: - - mal -m 'hello!' -t joe@example.org -u you -P password123 \ - you+malbot@example.org - -CC john@example.org: - - mal -m 'hello!' -t joe@example.org -H 'Cc: ' -P password123 \ - you@example.org - -Read a quick usage example: - - mal - -Man pages hopefully coming soon. +All documentation is provided in the man page. With mal installed, run +`man mal`, or in this source tree run `man ./mal.1`. Usage examples are +in the **EXAMPLES** section near the end. From b5d42f082d192527deafae3b9f751d09d5455c1c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 17 Jun 2024 07:59:23 +1200 Subject: [PATCH 09/10] mal-1.0 --- mal.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mal.d b/mal.d index a79dfd0..bada251 100644 --- a/mal.d +++ b/mal.d @@ -119,7 +119,7 @@ main(string[] args) } if (showVersion) { - writeln("mal version 0.0.0"); + writeln("mal version 1.0"); return 0; } From 046dcc441fb489ade85778d646ebb547cd687a77 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 30 Apr 2025 12:10:36 +1200 Subject: [PATCH 10/10] rename README.md to README --- README | 13 +++++++++++++ README.md | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 README delete mode 100644 README.md diff --git a/README b/README new file mode 100644 index 0000000..35f0de8 --- /dev/null +++ b/README @@ -0,0 +1,13 @@ +mal sends mail to one or more recipients, through information passed +on its command line. Read COPYING for information on redistribution. + +* Building + +With ldc and libcurl installed, run: + + $ make + # make install # to install + +Documentation is provided in the man page. + +Written by Jeremy Baxter diff --git a/README.md b/README.md deleted file mode 100644 index bd38d64..0000000 --- a/README.md +++ /dev/null @@ -1,13 +0,0 @@ -mal sends email to one or more recipients, through information passed -on its command line. Read COPYING for information on redistribution. - -## compilation - -Install ldc and libcurl, and run `make`. -To install, run `make install` after compiling. - -## documentation - -All documentation is provided in the man page. With mal installed, run -`man mal`, or in this source tree run `man ./mal.1`. Usage examples are -in the **EXAMPLES** section near the end.