public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin-apps@cygwin.com
Subject: Re: cygport announce fails unable to find mailserver
Date: Sat, 24 Oct 2020 17:19:11 -0600	[thread overview]
Message-ID: <1c6c74ec-4066-1a8b-fba3-ec13f32b4c37@SystematicSw.ab.ca> (raw)
In-Reply-To: <573f6609-fbde-c8b1-050d-dbf48651db79@SystematicSw.ab.ca>

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

On 2020-10-24 16:21, Brian Inglis wrote:
> On 2020-10-24 15:42, Ken Brown via Cygwin-apps wrote:
>> On 10/24/2020 4:53 PM, Brian Inglis wrote:
>>> Do any/some/many of you use cygport ...cygport announce to generate your update
>>> announcements, and does it work successfully?
>>
>> I use it.  You have to set several SMTP_* variables in your ~/.cygport.conf.  If
>> you don't already have that file, copy /etc/cygport.conf to ~/.cygport.conf and
>> edit it.
> 
> Thanks, already set up with SMTP_SERVER=smtp which is all I need from my home
> ISP connection for all SMTP clients (POP3, web, mobile needs user and password).
> Nothing else is required (yet)!

Hacked out the perl code into a file and got it running and failing.
Added Net:SMTP() Debug parameter and set it.
Problem is ISP SMTP MX will not accept localhost.localdomain as EHLO/HELO
maildomain!

So added parameter with other value and it worked.

See Failure and Success logs below.

With a bit more work, we can get the default local host network domain name (ISP
or org), and update that from the sender email address if available.

+use Net::Domain qw(hostdomain);
+my $hello = hostdomain();
+$hello = $1 if ($entity->head->get('From') =~ m/<?[^@>]+@([^>]+)>?/);
+my $smtp = new Net::SMTP($smtp_server,
			  Port => 25,
+			  Hello => $hello,
#			  Debug => 1,
			  SSL => $smtp_encryption eq 'ssl')
+	or die "No mailserver at ".$smtp_server.":".$@;

A functional patch is attached, but someone who really knows what they're doing
with SMTP, Perl, embedding the latter in shell scripts, and getting them to work
needs to apply something like this, make it a conditional setting based on
another cygport config flag e.g. SMTP_HELLO=1, or some enumeration.

It should also be possible to handle the STARTTLS response and switch the
connection to be encrypted, but that is way over my head in Perl.

Failure log:

$ src/cygwin/cygport-pkg-announce-email.pl
Sending announcement of tzcode 2020d via smtp
Net::SMTP>>> Net::SMTP(3.11)
Net::SMTP>>>   Net::Cmd(3.11)
Net::SMTP>>>     Exporter(5.73)
Net::SMTP>>>   IO::Socket::IP(0.39)
Net::SMTP>>>     IO::Socket(1.40)
Net::SMTP>>>       IO::Handle(1.40)
Net::SMTP=GLOB(0x80112a000)<<< 220 mo22.dcs.int.inet ...ca ESMTP server ready
Net::SMTP=GLOB(0x80112a000)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x80112a000)<<< 501 EHLO invalid ehlo (localhost.localdomain)
Net::SMTP=GLOB(0x80112a000)>>> HELO localhost.localdomain
Net::SMTP: Net::Cmd::getline(): unexpected EOF on command channel:  at
src/cygwin/cygport-pkg-announce-email.pl line 27.
No mailserver at smtp:Net::SMTP: 421 [Net::SMTP] Connection closed at
src/cygwin/cygport-pkg-announce-email.pl line 27.

[SMTP 421 means Try again later]

Success log:

$ src/cygwin/cygport-pkg-announce-email.pl
Sending announcement of tzcode 2020d via smtp
Net::SMTP>>> Net::SMTP(3.11)
Net::SMTP>>>   Net::Cmd(3.11)
Net::SMTP>>>     Exporter(5.73)
Net::SMTP>>>   IO::Socket::IP(0.39)
Net::SMTP>>>     IO::Socket(1.40)
Net::SMTP>>>       IO::Handle(1.40)
Net::SMTP=GLOB(0x80110cf10)<<< 220 mo24.dcs.int.inet ...ca ESMTP server ready
Net::SMTP=GLOB(0x80110cf10)>>> EHLO SystematicSW.ab.ca
Net::SMTP=GLOB(0x80110cf10)<<< 250-mo24.dcs.int.inet hello [...], pleased to
meet you
Net::SMTP=GLOB(0x80110cf10)<<< 250-HELP
Net::SMTP=GLOB(0x80110cf10)<<< 250-SIZE 29360128
Net::SMTP=GLOB(0x80110cf10)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x80110cf10)<<< 250-8BITMIME
Net::SMTP=GLOB(0x80110cf10)<<< 250-STARTTLS
Net::SMTP=GLOB(0x80110cf10)<<< 250 OK
Net::SMTP=GLOB(0x80110cf10)>>> MAIL FROM:<Brian.Inglis@SystematicSW.ab.ca>
Net::SMTP=GLOB(0x80110cf10)<<< 250 2.1.0 <brian.inglis@systematicsw.ab.ca> sender ok
Net::SMTP=GLOB(0x80110cf10)>>> RCPT TO:<cygwin-announce@cygwin.com>
Net::SMTP=GLOB(0x80110cf10)<<< 250 2.1.5 <cygwin-announce@cygwin.com> recipient ok
Net::SMTP=GLOB(0x80110cf10)>>> DATA
...
Net::SMTP=GLOB(0x80110cf10)>>> .
NNet::SMTP=GLOB(0x80110cf10)<<< 250 2.0.0 WSGzktx91RAWfWSH1kHFQt mail accepted
for delivery
Net::SMTP=GLOB(0x80110cf10)>>> QUIT
Net::SMTP=GLOB(0x80110cf10)<<< 221 2.0.0 mo24.dcs.int.inet ...ca closing connection
Announcement sent

-- 
-- 
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: 1673 bytes --]

--- a/pkg_upload.cygpart	2019-03-04 19:28:36.593859100 -0700
+++ b/pkg_upload.cygpart	2020-10-24 17:11:34.699008700 -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
@@ -202,6 +202,7 @@ _EOF
 use strict;
 use MIME::Parser;
 use Net::SMTP;
+use Net::Domain qw(hostdomain);
 
 my \$smtp_server = "${SMTP_SERVER:-localhost}";
 my \$smtp_encryption = "${SMTP_ENCRYPTION:-none}";
@@ -214,10 +215,13 @@ my \$entity = \$parser->parse_open("$msg
 
 print "Sending announcement of ${NAME}-${PVR} via \$smtp_server\n";
 
+my \$hello = hostdomain();
+\$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');

  reply	other threads:[~2020-10-24 23:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-24 20:53 Brian Inglis
2020-10-24 21:42 ` Ken Brown
2020-10-24 22:21   ` Brian Inglis
2020-10-24 23:19     ` Brian Inglis [this message]
2020-10-24 23:50       ` Jon Turney
2020-10-25  4:37         ` Brian Inglis
2020-10-25 16:18           ` Brian Inglis

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=1c6c74ec-4066-1a8b-fba3-ec13f32b4c37@SystematicSw.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin-apps@cygwin.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).