From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id C9B9424A60 for ; Fri, 17 May 2024 00:53:13 +0200 (CEST) Received: from pb-smtp20.pobox.com ([173.228.157.52]) by 9front; Thu May 16 18:50:55 -0400 2024 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 1118D29347 for <9front@9front.org>; Thu, 16 May 2024 18:50:52 -0400 (EDT) (envelope-from me+unobe@fallglow.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :date:from:to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=79mxJ6m2n8mMce8QgK3w4Rurc WpnvGY1d7I9RWqcLIk=; b=GGKfyTzk76vionPAVtszEhyZoatN/Ku/j0qyyZL+8 F+yn2DqdFE1m87VIXTs+VWl6CN+ATER6IQsw3rxDC1bKigTSXViiTZ9YTDmwnIGP Op8VkDEtg75FSxDGM2WHrMjRIA1m0KjhKwhd/GQXVfAiR9BB6zs3MJNy7CN5fQ+C pA= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 0969129346 for <9front@9front.org>; Thu, 16 May 2024 18:50:52 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Received: from strider.localdomain (unknown [47.37.156.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 7A5BA29345 for <9front@9front.org>; Thu, 16 May 2024 18:50:48 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Message-ID: Date: Thu, 16 May 2024 15:50:46 -0700 From: Romano To: 9front@9front.org In-Reply-To: <11AEA4EE6266EBCACF531DE32D2AA5B8@smtp.pobox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: BCEF9196-13D6-11EF-B9E8-F515D2CDFF5E-09620299!pb-smtp20.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: basic ACPI over ACPI reduce/map-oriented high-performance generator Subject: Re: [9front] [PATCH] upas: allow send to parse e-mail descriptions like marshal Reply-To: 9front@9front.org Precedence: bulk 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 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 ") and sets the from to just the e-mail address portion. This does the same for upas/send so that upasname='A name ' 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 +#include #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);