public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH cygport] Fix announce to work with ISP SMTP servers
@ 2021-01-10  5:50 Brian Inglis
  2021-01-10  7:22 ` [PATCH v2 " Brian Inglis
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Inglis @ 2021-01-10  5:50 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 938 bytes --]

Please apply the attached patch to avoid my further spamming of the announce 
list again, as my ISP SMTP server requires a valid SMTP Hello domain, does not 
accept Unix Mbox 'From '  initial header line, and various other requirements to 
work reliably for sending, and receiving at sourceware.

The changes were based on git-send-email SMTP exchanges, which have never been 
an issue.
They main parts are implemented behind flag variables
SMTP_HELLO_DOMAIN (default 1 - fixes my issue and should work generally) and 
SMTP_MBOX_FROM (default 0 - fixes my issue and should work generally),
which could be supported in cygport.conf, but I have not yet made doc patches, 
as I would like feedback if there are any issues with the changes or flag 
variable names, being a plain, not Perl, scripter ;^>

Other tweaks were required to make the headers more SMTP compliant and to avoid 
issues with picky (configuration of?) ISP SMTP servers.


[-- Attachment #2: cygport-lib-pkg_upload.patch --]
[-- Type: text/plain, Size: 3363 bytes --]

cygport-lib-pkg_upload.cygpart(__pkg_announce): use non-default Hello string

update copyright year
(__pkg_upload): source package includes -src.hint
(__pkg_announce): drop first From header as it gets treated as data;
quote addresses in <>; add Reply-To: <cygwin@\...> header;
override Net:SMTP default Hello string localhost.localdomain with 
ISP/org host domain; could optionally be FQDN or just domain name;
override with From: address domain if available;
add Net::SMTP Hello parameter and value;
add extra failure diagnostic output;
add Cc and Bcc recipients if headers added

--- a/pkg_upload.cygpart	2019-03-04 19:28:36.593859100 -0700
+++ b/pkg_upload.cygpart	2020-10-25 01:13:35.236753400 -0600
@@ -2,8 +2,8 @@
 #
 # pkg_upload.cygpart - cygport package uploading functions
 #
-# Copyright (C) 2014-2019 Yaakov Selkowitz, Andrew Schulman
-# Provided by the Cygwin Ports project <http://sourceware.org/cygwinports/>
+# Copyright (C) 2014-2020 Cygport authors
+# Provided by the Cygwin project <https://cygwin.com/>
 #
 # cygport is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -81,7 +81,7 @@ __pkg_upload() {
 
 	# Check that binary and source package files exist
 
-	pkg_files=("${NAME}/${NAME}-${PVR}-src.tar.xz" "${NAME}/${NAME}-${PVR}.hint")
+	pkg_files=("${NAME}/${NAME}-${PVR}-src.tar.xz" "${NAME}/${NAME}-${PVR}-src.hint")
 
 	while (( n < pkg_count ))
 	do
@@ -173,10 +173,11 @@ __pkg_announce() {
 	local msgat=$(date +@%s)
 	local -i n=0
 
+#From cygwin-announce-${PF} $(date '+%a %b %d %H:%M:%S %Y' --date=${msgat})
 	cat > ${msg} <<_EOF
-From cygwin-announce-${PF} $(date '+%a %b %d %H:%M:%S %Y' --date=${msgat})
 From: ${SMTP_SENDER}
-To: cygwin-announce@cygwin.com
+To: <cygwin-announce@cygwin.com>
+Reply-To: <cygwin@cygwin.com>
 Date: $(date -R --date=${msgat})
 Message-Id: <$(date "+%Y%m%d%H%M%S.$$" --date=${msgat})-1-$(echo ${SMTP_SENDER} | sed 's|.*<\(.*\)>.*|\1|')>
 Subject: ${NAME} ${PVR}
@@ -202,6 +203,7 @@ _EOF
 use strict;
 use MIME::Parser;
 use Net::SMTP;
+use Net::Domain qw(hostdomain hostfqdn domainname);
 
 my \$smtp_server = "${SMTP_SERVER:-localhost}";
 my \$smtp_encryption = "${SMTP_ENCRYPTION:-none}";
@@ -214,10 +216,13 @@ my \$entity = \$parser->parse_open("$msg
 
 print "Sending announcement of ${NAME}-${PVR} via \$smtp_server\n";
 
+my \$hello = hostdomain(); # hostfqdn(); domainname();
+\$hello = \$1 if (\$entity->head->get('From') =~ m/<?[^@>]+@([^>]+)>?/);
 my \$smtp = new Net::SMTP(\$smtp_server,
 			  ${SMTP_SERVER_PORT+Port => ${SMTP_SERVER_PORT},}
+			  Hello => \$hello,
 			  SSL => \$smtp_encryption eq 'ssl')
-	 or die "No mailserver at ".\$smtp_server;
+	 or die "No mailserver at ".\$smtp_server.":".\$@;
 if (\$smtp_encryption eq 'tls') {
 	require Net::SMTP::SSL;
 	\$smtp->command('STARTTLS');
@@ -233,6 +238,8 @@ if (defined \$smtp_user) {
 }
 \$smtp->mail(\$entity->head->get('From')) or die "unable to set sender";
 \$smtp->to(\$entity->head->get('To')) or die "unable to address message";
+\$smtp->cc(\$entity->head->get('Cc')) if \$entity->head->get('Cc');
+\$smtp->bcc(\$entity->head->get('Bcc')) if \$entity->head->get('Bcc');
 \$smtp->data() or die "unable to start data send";
 \$smtp->datasend(\$entity->as_string()) or die "Message send failed";
 \$smtp->dataend() or die "Message end failed";

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 cygport] Fix announce to work with ISP SMTP servers
  2021-01-10  5:50 [PATCH cygport] Fix announce to work with ISP SMTP servers Brian Inglis
@ 2021-01-10  7:22 ` Brian Inglis
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Inglis @ 2021-01-10  7:22 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

On 2021-01-09 22:50, Brian Inglis wrote:
> Please apply the attached patch to avoid my further spamming of the announce 
> list again, as my ISP SMTP server requires a valid SMTP Hello domain, does not 
> accept Unix Mbox 'From '  initial header line, and various other requirements to 
> work reliably for sending, and receiving at sourceware.
> 
> The changes were based on git-send-email SMTP exchanges, which have never been 
> an issue.
> They main parts are implemented behind flag variables
> SMTP_HELLO_DOMAIN (default 1 - fixes my issue and should work generally) and 
> SMTP_MBOX_FROM (default 0 - fixes my issue and should work generally),
> which could be supported in cygport.conf, but I have not yet made doc patches, 
> as I would like feedback if there are any issues with the changes or flag 
> variable names, being a plain, not Perl, scripter ;^>
> 
> Other tweaks were required to make the headers more SMTP compliant and to avoid 
> issues with picky (configuration of?) ISP SMTP servers.

Resend with current patch.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

[-- Attachment #2: cygport-lib-pkg_upload.patch --]
[-- Type: text/plain, Size: 4339 bytes --]

--- a/cygport/lib/pkg_upload.cygpart	2020-07-10 17:02:29.781319400 -0600
+++ b/cygport/lib/pkg_upload.cygpart	2020-10-26 02:21:08.690020000 -0600
@@ -168,16 +168,21 @@ EOF
 	echo "Upload complete."
 }
 
-
 __pkg_announce() {
 	local msg=$(mktemp -t cygwin-announce-${PF}.XXXXXX)
 	local msgat=$(date +@%s)
 	local -i n=0
+	local smtp_mbox_from=${SMTP_MBOX_FROM:-0}
+
+	if [ $smtp_mbox_from = 1 ]
+	then
+	    echo "From cygwin-announce-${PF} $(date '+%a %b %d %H:%M:%S %Y' --date=${msgat})" >> ${msg}
+	fi
 
-	cat > ${msg} <<_EOF
-From cygwin-announce-${PF} $(date '+%a %b %d %H:%M:%S %Y' --date=${msgat})
+	cat >> ${msg} <<_EOF
 From: ${SMTP_SENDER}
-To: cygwin-announce@cygwin.com
+To: <cygwin-announce@cygwin.com>
+Reply-To: <cygwin@cygwin.com>
 Date: $(date -R --date=${msgat})
 Message-Id: <$(date "+%Y%m%d%H%M%S.$$" --date=${msgat})-1-$(echo ${SMTP_SENDER} | sed 's|.*<\(.*\)>.*|\1|')>
 Subject: ${NAME} ${PVR}
@@ -197,7 +202,7 @@ _EOF
 ${DESCRIPTION}
 _EOF
 
-	${EDITOR:-vi} $msg || error "Editor exited abormally, aborting annoucement"
+	${VISUAL:-${EDITOR:-vi}} $msg || error "Editor exited abormally, aborting announcement"
 
 # FQDN from git send-email
 # Returns the local Fully Qualified Domain Name (FQDN) if available.
@@ -215,8 +220,12 @@ _EOF
 #
 # This maildomain*() code is based on ideas in Perl library Test::Reporter
 # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
-
 	perl <(cat <<EOF
+use strict;
+use MIME::Parser;
+use Net::SMTP;
+use Net::Domain qw(hostdomain hostfqdn domainname);
+
 sub valid_fqdn {
 	my \$domain = shift;
 	return defined \$domain && !(\$^O eq 'darwin' && \$domain =~ /\.local\$/) && \$domain =~ /\./;
@@ -224,13 +233,13 @@ sub valid_fqdn {
 sub maildomain_net {
     use Net::Domain ();
 	my \$maildomain;
-	my \$domain = Net::Domain::domainname();
+	my \$domain = domainname();
 	\$maildomain = \$domain if valid_fqdn(\$domain);
 	return \$maildomain;
 }
 sub maildomain_mta {
 	my \$maildomain;
-	for my \$host (qw(mailhost localhost)) {
+	for my \$host (qw(mailhost localhost mail smtp)) {
 		my \$smtp = Net::SMTP->new(\$host);
 		if (defined \$smtp) {
 			my \$domain = \$smtp->domain;
@@ -245,27 +254,29 @@ sub maildomain {
 	return maildomain_net() || maildomain_mta() || 'localhost.localdomain';
 }
 
-use strict;
-use MIME::Parser;
-use Net::SMTP;
-
 my \$smtp_server = "${SMTP_SERVER:-localhost}";
 my \$smtp_encryption = "${SMTP_ENCRYPTION:-none}";
 my \$smtp_user${SMTP_USER+ = '$SMTP_USER'};
 my \$smtp_pass${SMTP_PASS+ = '$SMTP_PASS'};
+my \$smtp_hello_domain = "${SMTP_HELLO_DOMAIN:-1}";
+my \$hello = 'localhost.localdomain';
+# get FQDN and add Hello below
+\$hello ||= hostfqdn() || hostdomain() || maildomain() if \$smtp_hello_domain;
 
 my \$parser = new MIME::Parser;
 \$parser->output_to_core(1);
 my \$entity = \$parser->parse_open("$msg");
+if (\$smtp_hello_domain) {
+	\$hello = \$1 if (\$entity->head->get('From') =~ m/<?[^@>]+@([^>]+)>?/);
+}
 
 print "Sending announcement of ${NAME}-${PVR} via \$smtp_server\n";
 
-my \$smtp_domain ||= maildomain();  # get FQDN and add Hello below
 my \$smtp = new Net::SMTP(\$smtp_server,
-			  Hello => \$smtp_domain,
 			  ${SMTP_SERVER_PORT+Port => ${SMTP_SERVER_PORT},}
+			  Hello => \$hello,
 			  SSL => \$smtp_encryption eq 'ssl')
-	 or die "No mailserver at ".\$smtp_server;
+	 or die "No mailserver at ".\$smtp_server.":".\$@;
 if (\$smtp_encryption eq 'tls') {
 	require Net::SMTP::SSL;
 	\$smtp->command('STARTTLS');
@@ -273,7 +284,7 @@ if (\$smtp_encryption eq 'tls') {
 	\$smtp->code == 220 or die "$server does not support STARTTLS";
 	\$smtp = Net::SMTP::SSL->start_SSL(\$smtp) or die "STARTTLS failed";
 	# Send EHLO again to receive fresh supported commands
-	\$smtp->hello(\$smtp_domain);
+	\$smtp->hello(\$hello);
 }
 if (defined \$smtp_user) {
 	use Authen::SASL qw(Perl);
@@ -282,6 +293,8 @@ if (defined \$smtp_user) {
 }
 \$smtp->mail(\$entity->head->get('From')) or die "unable to set sender";
 \$smtp->to(\$entity->head->get('To')) or die "unable to address message";
+\$smtp->cc(\$entity->head->get('Cc')) if \$entity->head->get('Cc');
+\$smtp->bcc(\$entity->head->get('Bcc')) if \$entity->head->get('Bcc');
 \$smtp->data() or die "unable to start data send";
 \$smtp->datasend(\$entity->as_string()) or die "Message send failed";
 \$smtp->dataend() or die "Message end failed";

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-10  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10  5:50 [PATCH cygport] Fix announce to work with ISP SMTP servers Brian Inglis
2021-01-10  7:22 ` [PATCH v2 " Brian Inglis

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 read-only IMAP folder(s) and NNTP newsgroup(s).