From: Romano <me+unobe@fallglow.com>
To: 9front@9front.org
Subject: Re: [9front] [PATCH] upas: allow send to parse e-mail descriptions like marshal
Date: Thu, 16 May 2024 15:50:46 -0700 [thread overview]
Message-ID: <FF3A32AD5C1A06D210B478808E525CE0@smtp.pobox.com> (raw)
In-Reply-To: <11AEA4EE6266EBCACF531DE32D2AA5B8@smtp.pobox.com>
Looking at my initial patch, I don't think *r is needed at all:
*cp can just be used. Attached is an updated patch, which I submit
for consideration.
For a bit more background, this patch is ideal for someone who is using
upas with different smtp providers, or using the typical '+'/'-' format
to the localpart for categorization. For instance, in /mail/lib/fromfiles,
a file can be specified listing an email address and smtp server separated
by whitespace. /mail/lib/remotemail can then be modified to account
for the output of aliasmail and then connect the the appropriate smtp
server:
cpu% cat /mail/lib/remotemail
#!/bin/rc
shift
sender=$1
shift
addr=$1
shift
fd=`{/bin/upas/aliasmail -f $sender}
switch($fd){
case smtp.server1.com
addr=(-a -t -u username1 tcp!$fd!ssmtp)
case smtp.server2.com
addr=(-a -t -u username tcp!$fd!ssmtp)
case *.*
;
case *
fd=your.domain
# for now, just fail at this point
echo `{date} 'no host found in remotemail! sender='^$sender >> /sys/log/remotemail
exit `{date} 'no host found in remotemail!'
}
exec /bin/upas/smtp -h $fd $addr $sender $*
As explained below, upas/marshal already gets the right sender
when given an e-mail description defined in $upasname, so this is
making it so that further parsing and processing doesn't need to be
done by remotemail.
To me, this makes sense, but is this a bad idea? Is there a reason
why upas/marshal would take the pains to extract the e-mail from
$upasname correctly but not upas/send?
From: Romano <unobe@cpan.org>
Date: Wed, 15 May 2024 09:34:51 +0000
Subject: [PATCH] upas: allow send to parse e-mail descriptions like marshal
upas/marshal/marshal.c:/^printfrom parses an e-mail with a description
(e.g., "A Name <a.name@example.com>") and sets the from to just the
e-mail address portion. This does the same for upas/send so that
upasname='A name <a.name@example.com>' can be used to both set the From:
in marshal with a description and to match the correct from in send
for sending via smtp.
---
diff e51d4aa069548de51d0e88a6d621d278e9138cd0 7f8780f7b92fbbc37704d4d48ccd15ab1b1e5a27
--- a/sys/src/cmd/upas/send/message.c
+++ b/sys/src/cmd/upas/send/message.c
@@ -1,6 +1,7 @@
#include "common.h"
#include "send.h"
#include <regexp.h>
+#include <ctype.h>
#include "../smtp/smtp.h"
#include "../smtp/rfc822.tab.h"
@@ -18,6 +19,24 @@
static String* getstring(Node *p);
static String* getaddr(Node *p);
+char *
+userfrom(char *cp)
+{
+ char *s;
+ int n;
+
+ if((n = strlen(cp)) > 4 && cp[n-1] == '>'){
+ if((s = strrchr(cp, '<')) != nil && s != cp && isspace(s[-1])) {
+ s++;
+ strncpy(cp, s, n - sizeof s);
+ cp[strlen(s)-1] = '\0';
+ return cp;
+ }
+ }
+
+ return cp;
+}
+
int
default_from(message *mp)
{
@@ -32,7 +51,7 @@
return -1;
}
if(cp && *cp)
- s_append(mp->sender, cp);
+ s_append(mp->sender, userfrom(cp));
else
s_append(mp->sender, lp);
free(cp);
next prev parent reply other threads:[~2024-05-16 22:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 7:22 Romano
2024-05-16 22:50 ` Romano [this message]
2024-05-17 8:23 ` Romano
2024-06-18 18:05 ` Romano
2024-06-19 22:53 ` Jacob Moody
2024-06-20 5:27 ` Romano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FF3A32AD5C1A06D210B478808E525CE0@smtp.pobox.com \
--to=me+unobe@fallglow.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).