[PATCH cygport] Fix announce to work with ISP SMTP servers

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Sun Jan 10 05:50:31 GMT 2021


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.

-------------- next part --------------
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";


More information about the Cygwin-apps mailing list