comp.lang.ada
 help / color / mirror / Atom feed
* Attempt to send email using AWS results in Socket closed by peer
@ 2021-09-01 18:58 Juan Rayas
  2021-09-01 19:43 ` Dmitry A. Kazakov
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Juan Rayas @ 2021-09-01 18:58 UTC (permalink / raw)


Hi,

 I am teaching myself Ada and tried to create a simple program that sends an email if today's date equals my birthday :).

 I am using Gnat Studio 2021, Community edition, Ubuntu 20.0.4. I downloaded, built and installed AWS. I am sending the email as follows:

procedure SendMail is
      Status : AWS.SMTP.Status;
      Auth   : aliased constant SMTP.Authentication.Plain.Credential :=
        SMTP.Authentication.Plain.Initialize
          ("myAccount", "myPassword");
      Isp : SMTP.Receiver;

   begin
      New_Line;
      Isp :=
        SMTP.Client.Initialize
          ("smtp.gmail.com", Port => 465, 
           Credential             => Auth'Unchecked_Access);

      SMTP.Client.Send
        (Isp, From => SMTP.E_Mail ("Me", "myAccount"),
         To        => SMTP.E_Mail ("Me", "myAccount"),
         Subject   => "AWS test", 
         Message   => "This is a test",
         Status    => Status);

      if not SMTP.Is_Ok (Status) then
         Text_IO.Put_Line
           ("Can't send message :" & SMTP.Status_Message (Status));
      end if;
   end SendMail;

myAccount and myPassword are removed for the purposes of  this post.

When I run my program, the SendEmail procedure fails with the following message:

raised AWS.SMTP.SERVER_ERROR : raised AWS.NET.SOCKET_ERROR : Receive : Socket closed by peer

Does anyone know how to fix this when using the gmail server? Or perhaps I am using AWS incorrectly?

Thanks,
Juan

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
@ 2021-09-01 19:43 ` Dmitry A. Kazakov
  2021-09-02 22:19   ` Randy Brukardt
  2021-09-01 20:02 ` Dennis Lee Bieber
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Dmitry A. Kazakov @ 2021-09-01 19:43 UTC (permalink / raw)


On 2021-09-01 20:58, Juan Rayas wrote:

> Does anyone know how to fix this when using the gmail server?

No, but I guess that you must configure the SMTP client for TLS or else 
opportunistic TLS (StartTLS). Most mail servers do not accept 
unencrypted connections. I do not use AWS and its SMTP, maybe somebody 
who does might help you with it.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
  2021-09-01 19:43 ` Dmitry A. Kazakov
@ 2021-09-01 20:02 ` Dennis Lee Bieber
  2021-09-02  3:29 ` Richard Iswara
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Dennis Lee Bieber @ 2021-09-01 20:02 UTC (permalink / raw)


On Wed, 1 Sep 2021 11:58:47 -0700 (PDT), Juan Rayas
<juan.m.rayas@gmail.com> declaimed the following:


>Does anyone know how to fix this when using the gmail server? Or perhaps I am using AWS incorrectly?
>
	My first suggestion would be: don't use the gmail server!

	If you must use it, you'll likely need to configure gmail for "less
secure apps" (basically anything that isn't a Google product <G>).
Google/Gmail wants OAUTH2 or something like that, along with TLS/SSL. "Less
secure" means bypassing the OAUTH2 scheme.

	I wouldn't  be surprised if they want you to set up a password for each
device used to connect...



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
  2021-09-01 19:43 ` Dmitry A. Kazakov
  2021-09-01 20:02 ` Dennis Lee Bieber
@ 2021-09-02  3:29 ` Richard Iswara
  2021-09-02  4:03 ` Doctor Who
  2021-09-03 20:35 ` Simon Wright
  4 siblings, 0 replies; 15+ messages in thread
From: Richard Iswara @ 2021-09-02  3:29 UTC (permalink / raw)


On 02/09/2021 01.58, Juan Rayas wrote:
> Hi,
> 
>   I am teaching myself Ada and tried to create a simple program that sends an email if today's date equals my birthday :).
> 
>   I am using Gnat Studio 2021, Community edition, Ubuntu 20.0.4. I downloaded, built and installed AWS. I am sending the email as follows:
> 
> procedure SendMail is
>        Status : AWS.SMTP.Status;
>        Auth   : aliased constant SMTP.Authentication.Plain.Credential :=
>          SMTP.Authentication.Plain.Initialize
>            ("myAccount", "myPassword");
>        Isp : SMTP.Receiver;
> 
>     begin
>        New_Line;
>        Isp :=
>          SMTP.Client.Initialize
>            ("smtp.gmail.com", Port => 465,
>             Credential             => Auth'Unchecked_Access);
> 
>        SMTP.Client.Send
>          (Isp, From => SMTP.E_Mail ("Me", "myAccount"),
>           To        => SMTP.E_Mail ("Me", "myAccount"),
>           Subject   => "AWS test",
>           Message   => "This is a test",
>           Status    => Status);
> 
>        if not SMTP.Is_Ok (Status) then
>           Text_IO.Put_Line
>             ("Can't send message :" & SMTP.Status_Message (Status));
>        end if;
>     end SendMail;
> 
> myAccount and myPassword are removed for the purposes of  this post.
> 
> When I run my program, the SendEmail procedure fails with the following message:
> 
> raised AWS.SMTP.SERVER_ERROR : raised AWS.NET.SOCKET_ERROR : Receive : Socket closed by peer
> 
> Does anyone know how to fix this when using the gmail server? Or perhaps I am using AWS incorrectly?
> 
> Thanks,
> Juan
> 

Use a public email test server for testing program. Places like these: 
https://www.bing.com/search?form=MOZLBR&pc=MOZI&q=email+test+servers. It 
will show what's the received and sent responses.
The Gmail server marked your message as spam or worse and simply ignored 
your message.

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
                   ` (2 preceding siblings ...)
  2021-09-02  3:29 ` Richard Iswara
@ 2021-09-02  4:03 ` Doctor Who
  2021-09-02 22:22   ` Randy Brukardt
  2021-09-03 20:35 ` Simon Wright
  4 siblings, 1 reply; 15+ messages in thread
From: Doctor Who @ 2021-09-02  4:03 UTC (permalink / raw)


On Wed, 1 Sep 2021 11:58:47 -0700 (PDT), Juan Rayas
<juan.m.rayas@gmail.com> wrote:

>Hi,
>
> I am teaching myself Ada and tried to create a simple program that sends an email if today's date equals my birthday :).
>
> I am using Gnat Studio 2021, Community edition, Ubuntu 20.0.4. I downloaded, built and installed AWS. I am sending the email as follows:
>
>procedure SendMail is
>      Status : AWS.SMTP.Status;
>      Auth   : aliased constant SMTP.Authentication.Plain.Credential :=
>        SMTP.Authentication.Plain.Initialize
>          ("myAccount", "myPassword");
>      Isp : SMTP.Receiver;
>
>   begin
>      New_Line;
>      Isp :=
>        SMTP.Client.Initialize
>          ("smtp.gmail.com", Port => 465, 
>           Credential             => Auth'Unchecked_Access);
>
>      SMTP.Client.Send
>        (Isp, From => SMTP.E_Mail ("Me", "myAccount"),
>         To        => SMTP.E_Mail ("Me", "myAccount"),
>         Subject   => "AWS test", 
>         Message   => "This is a test",
>         Status    => Status);
>
>      if not SMTP.Is_Ok (Status) then
>         Text_IO.Put_Line
>           ("Can't send message :" & SMTP.Status_Message (Status));
>      end if;
>   end SendMail;
>
>myAccount and myPassword are removed for the purposes of  this post.
>
>When I run my program, the SendEmail procedure fails with the following message:
>
>raised AWS.SMTP.SERVER_ERROR : raised AWS.NET.SOCKET_ERROR : Receive : Socket closed by peer
>
>Does anyone know how to fix this when using the gmail server? Or perhaps I am using AWS incorrectly?
>
>Thanks,
>Juan


port 465 wants a TLS connection.

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 19:43 ` Dmitry A. Kazakov
@ 2021-09-02 22:19   ` Randy Brukardt
  2021-09-03  7:32     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 15+ messages in thread
From: Randy Brukardt @ 2021-09-02 22:19 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:sgol48$r20$1@gioia.aioe.org...
...
> Most mail servers do not accept unencrypted connections.

That's news to me, as my mail server (you know, the one that runs 
Ada-Comment and the other ARG lists) doesn't support encrypted connections. 
I don't have any problem sending to GMail (I send copies of most of my 
personal mail there). Something else must be wrong.

                                    Randy.


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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-02  4:03 ` Doctor Who
@ 2021-09-02 22:22   ` Randy Brukardt
  0 siblings, 0 replies; 15+ messages in thread
From: Randy Brukardt @ 2021-09-02 22:22 UTC (permalink / raw)



"Doctor Who" <doc@tardis.org> wrote in message 
news:57j0jgd920r1al3ehsbilbs39041c3eeqd@4ax.com...
...
> port 465 wants a TLS connection.

Good point. One uses port 25 for ordinary e-mail. One does not need to 
authenticate to most public e-mail servers (of course, if you don't, you'll 
be subjected to increased spam checks, but that usually isn't a problem if 
you aren't sending spam).

                       Randy.


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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-02 22:19   ` Randy Brukardt
@ 2021-09-03  7:32     ` Dmitry A. Kazakov
  2021-09-03  8:59       ` Doctor Who
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry A. Kazakov @ 2021-09-03  7:32 UTC (permalink / raw)


On 2021-09-03 00:19, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:sgol48$r20$1@gioia.aioe.org...
> ...
>> Most mail servers do not accept unencrypted connections.
> 
> That's news to me, as my mail server (you know, the one that runs
> Ada-Comment and the other ARG lists) doesn't support encrypted connections.
> I don't have any problem sending to GMail (I send copies of most of my
> personal mail there). Something else must be wrong.

The question is with what settings. There are hundreds of combinations 
of Port x unencrypted|StartTLS|TLS x authentication method.

The port 465 was intended for TLS, then it was depreciated. Then they 
introduced other ports. Legacy mail servers pissed that all on etc.

 From experience, getting a SMTP client working is real pain.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03  7:32     ` Dmitry A. Kazakov
@ 2021-09-03  8:59       ` Doctor Who
  2021-09-03 18:11         ` Juan Rayas
  0 siblings, 1 reply; 15+ messages in thread
From: Doctor Who @ 2021-09-03  8:59 UTC (permalink / raw)


On Fri, 3 Sep 2021 09:32:27 +0200, "Dmitry A. Kazakov"
<mailbox@dmitry-kazakov.de> wrote:

>On 2021-09-03 00:19, Randy Brukardt wrote:
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>> news:sgol48$r20$1@gioia.aioe.org...
>> ...
>>> Most mail servers do not accept unencrypted connections.
>> 
>> That's news to me, as my mail server (you know, the one that runs
>> Ada-Comment and the other ARG lists) doesn't support encrypted connections.
>> I don't have any problem sending to GMail (I send copies of most of my
>> personal mail there). Something else must be wrong.
>
>The question is with what settings. There are hundreds of combinations 
>of Port x unencrypted|StartTLS|TLS x authentication method.
>
>The port 465 was intended for TLS, then it was depreciated. Then they 
>introduced other ports. Legacy mail servers pissed that all on etc.
>
> From experience, getting a SMTP client working is real pain.

he is better off using his own provider's mail server on port 25, it
will accept username/password as authentication.

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03  8:59       ` Doctor Who
@ 2021-09-03 18:11         ` Juan Rayas
  2021-09-03 18:31           ` Dmitry A. Kazakov
  2021-09-03 19:33           ` Doctor Who
  0 siblings, 2 replies; 15+ messages in thread
From: Juan Rayas @ 2021-09-03 18:11 UTC (permalink / raw)


On Friday, September 3, 2021 at 1:59:33 AM UTC-7, Doctor Who wrote:
> On Fri, 3 Sep 2021 09:32:27 +0200, "Dmitry A. Kazakov" 
> <mai...@dmitry-kazakov.de> wrote: 
> 
> >On 2021-09-03 00:19, Randy Brukardt wrote: 
> >> "Dmitry A. Kazakov" <mai...@dmitry-kazakov.de> wrote in message 
> >> news:sgol48$r20$1...@gioia.aioe.org... 
> >> ... 
> >>> Most mail servers do not accept unencrypted connections. 
> >> 
> >> That's news to me, as my mail server (you know, the one that runs 
> >> Ada-Comment and the other ARG lists) doesn't support encrypted connections. 
> >> I don't have any problem sending to GMail (I send copies of most of my 
> >> personal mail there). Something else must be wrong. 
> > 
> >The question is with what settings. There are hundreds of combinations 
> >of Port x unencrypted|StartTLS|TLS x authentication method. 
> > 
> >The port 465 was intended for TLS, then it was depreciated. Then they 
> >introduced other ports. Legacy mail servers pissed that all on etc. 
> > 
> > From experience, getting a SMTP client working is real pain.
> he is better off using his own provider's mail server on port 25, it 
> will accept username/password as authentication.
Hi all,

 thank you for your comments and responses.

I tried changing the port number to 25, using the default port number in the SMTP.Client.Initialize procedure, and using other port numbers such as 587. I even tried just initializing the SMT server and sending the email (without authentication) as indicated in https://docs.adacore.com/aws-docs/aws/working_with_mails.html.

In all cases, I get the following error:

Can't send message :530 5.7.0 Must issue a STARTTLS command first. u7sm5705829pju.13 - gsmtp

The problem is I don't know how to send the STARTTLS command with AWS. Anyone know how?

My past experience was mostly with real-time embedded systems, so I don't have a lot of experience with email servers. I didn't expect this to be so difficult. Since this was mostly a toy to learn Ada, I may move on to other aspects of Ada for now.

Thanks for all your comments.
--Juan

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03 18:11         ` Juan Rayas
@ 2021-09-03 18:31           ` Dmitry A. Kazakov
  2021-09-03 19:33           ` Doctor Who
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry A. Kazakov @ 2021-09-03 18:31 UTC (permalink / raw)


On 2021-09-03 20:11, Juan Rayas wrote:

> In all cases, I get the following error:
> 
> Can't send message :530 5.7.0 Must issue a STARTTLS command first. u7sm5705829pju.13 - gsmtp
> 
> The problem is I don't know how to send the STARTTLS command with AWS. Anyone know how?

There should be some settings parameter instructing the client to send 
StartTLS right after it connects to the server. At least in my SMTP 
implementation it is so.

But again, either port 587 or StartTLS, both require TLS, e.g. over 
GNUTLS or else OpenSSL.

You need to tell AWS that you are going to use one them, specify the 
certificates, the keys etc. You must really read the AWS documentation 
regarding secure connections.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03 18:11         ` Juan Rayas
  2021-09-03 18:31           ` Dmitry A. Kazakov
@ 2021-09-03 19:33           ` Doctor Who
  2021-09-03 20:29             ` Juan Rayas
  1 sibling, 1 reply; 15+ messages in thread
From: Doctor Who @ 2021-09-03 19:33 UTC (permalink / raw)


On Fri, 3 Sep 2021 11:11:41 -0700 (PDT), Juan Rayas
<juan.m.rayas@gmail.com> wrote:

>On Friday, September 3, 2021 at 1:59:33 AM UTC-7, Doctor Who wrote:
>> On Fri, 3 Sep 2021 09:32:27 +0200, "Dmitry A. Kazakov" 
>> <mai...@dmitry-kazakov.de> wrote: 
>> 
>> >On 2021-09-03 00:19, Randy Brukardt wrote: 
>> >> "Dmitry A. Kazakov" <mai...@dmitry-kazakov.de> wrote in message 
>> >> news:sgol48$r20$1...@gioia.aioe.org... 
>> >> ... 
>> >>> Most mail servers do not accept unencrypted connections. 
>> >> 
>> >> That's news to me, as my mail server (you know, the one that runs 
>> >> Ada-Comment and the other ARG lists) doesn't support encrypted connections. 
>> >> I don't have any problem sending to GMail (I send copies of most of my 
>> >> personal mail there). Something else must be wrong. 
>> > 
>> >The question is with what settings. There are hundreds of combinations 
>> >of Port x unencrypted|StartTLS|TLS x authentication method. 
>> > 
>> >The port 465 was intended for TLS, then it was depreciated. Then they 
>> >introduced other ports. Legacy mail servers pissed that all on etc. 
>> > 
>> > From experience, getting a SMTP client working is real pain.
>> he is better off using his own provider's mail server on port 25, it 
>> will accept username/password as authentication.
>Hi all,
>
> thank you for your comments and responses.
>
>I tried changing the port number to 25, using the default port number in the SMTP.Client.Initialize procedure, and using other port numbers such as 587. I even tried just initializing the SMT server and sending the email (without authentication) as indicated in https://docs.adacore.com/aws-docs/aws/working_with_mails.html.
>
>In all cases, I get the following error:
>
>Can't send message :530 5.7.0 Must issue a STARTTLS command first. u7sm5705829pju.13 - gsmtp
>
>The problem is I don't know how to send the STARTTLS command with AWS. Anyone know how?
>
>My past experience was mostly with real-time embedded systems, so I don't have a lot of experience with email servers. I didn't expect this to be so difficult. Since this was mostly a toy to learn Ada, I may move on to other aspects of Ada for now.
>
>Thanks for all your comments.
>--Juan


you have to change mail server:

  Isp :=
        SMTP.Client.Initialize
          ("smtp.gmail.com", Port => 465, 
           Credential             => Auth'Unchecked_Access);

don't use gmail, use your provider mail server ...

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03 19:33           ` Doctor Who
@ 2021-09-03 20:29             ` Juan Rayas
  0 siblings, 0 replies; 15+ messages in thread
From: Juan Rayas @ 2021-09-03 20:29 UTC (permalink / raw)


On Friday, September 3, 2021 at 12:33:19 PM UTC-7, Doctor Who wrote:
> On Fri, 3 Sep 2021 11:11:41 -0700 (PDT), Juan Rayas 
> <juan.m...@gmail.com> wrote: 
> 
> >On Friday, September 3, 2021 at 1:59:33 AM UTC-7, Doctor Who wrote: 
> >> On Fri, 3 Sep 2021 09:32:27 +0200, "Dmitry A. Kazakov" 
> >> <mai...@dmitry-kazakov.de> wrote: 
> >> 
> >> >On 2021-09-03 00:19, Randy Brukardt wrote: 
> >> >> "Dmitry A. Kazakov" <mai...@dmitry-kazakov.de> wrote in message 
> >> >> news:sgol48$r20$1...@gioia.aioe.org... 
> >> >> ... 
> >> >>> Most mail servers do not accept unencrypted connections. 
> >> >> 
> >> >> That's news to me, as my mail server (you know, the one that runs 
> >> >> Ada-Comment and the other ARG lists) doesn't support encrypted connections. 
> >> >> I don't have any problem sending to GMail (I send copies of most of my 
> >> >> personal mail there). Something else must be wrong. 
> >> > 
> >> >The question is with what settings. There are hundreds of combinations 
> >> >of Port x unencrypted|StartTLS|TLS x authentication method. 
> >> > 
> >> >The port 465 was intended for TLS, then it was depreciated. Then they 
> >> >introduced other ports. Legacy mail servers pissed that all on etc. 
> >> > 
> >> > From experience, getting a SMTP client working is real pain. 
> >> he is better off using his own provider's mail server on port 25, it 
> >> will accept username/password as authentication. 
> >Hi all, 
> > 
> > thank you for your comments and responses. 
> > 
> >I tried changing the port number to 25, using the default port number in the SMTP.Client.Initialize procedure, and using other port numbers such as 587. I even tried just initializing the SMT server and sending the email (without authentication) as indicated in https://docs.adacore.com/aws-docs/aws/working_with_mails.html. 
> > 
> >In all cases, I get the following error: 
> > 
> >Can't send message :530 5.7.0 Must issue a STARTTLS command first. u7sm5705829pju.13 - gsmtp 
> > 
> >The problem is I don't know how to send the STARTTLS command with AWS. Anyone know how? 
> > 
> >My past experience was mostly with real-time embedded systems, so I don't have a lot of experience with email servers. I didn't expect this to be so difficult. Since this was mostly a toy to learn Ada, I may move on to other aspects of Ada for now. 
> > 
> >Thanks for all your comments. 
> >--Juan
> you have to change mail server:
> Isp := 
> SMTP.Client.Initialize 
> ("smtp.gmail.com", Port => 465, 
> Credential => Auth'Unchecked_Access);
> don't use gmail, use your provider mail server ...
Hi all,

 I changed the SMTP server to my ISP server (instead of Gmail), and changed the port back to 25. This worked!!

Thanks for your help and suggestions. Now on to learning other aspects of Ada.

--Juan

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
                   ` (3 preceding siblings ...)
  2021-09-02  4:03 ` Doctor Who
@ 2021-09-03 20:35 ` Simon Wright
  2021-09-03 21:13   ` Dmitry A. Kazakov
  4 siblings, 1 reply; 15+ messages in thread
From: Simon Wright @ 2021-09-03 20:35 UTC (permalink / raw)


Juan Rayas <juan.m.rayas@gmail.com> writes:

>       Isp :=
>         SMTP.Client.Initialize
>           ("smtp.gmail.com", Port => 465, 
>            Credential             => Auth'Unchecked_Access);

I succeed sending mail via gmail.com using port 587.

No useful further details on encryption - this was for the membership
d/b for a small club, and it's in Python/sqlite.

    self.server = smtplib.SMTP(host=self.server_details['host'],
                               port=self.server_details['port'])
    self.server.ehlo()
    self.server.starttls()
    self.server.ehlo()
    self.server.login\
        (user=server_details['user'],
         password=keyring.get_password\
           ('u3a-email', server_details['user']))

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

* Re: Attempt to send email using AWS results in Socket closed by peer
  2021-09-03 20:35 ` Simon Wright
@ 2021-09-03 21:13   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry A. Kazakov @ 2021-09-03 21:13 UTC (permalink / raw)


On 2021-09-03 22:35, Simon Wright wrote:
> Juan Rayas <juan.m.rayas@gmail.com> writes:
> 
>>        Isp :=
>>          SMTP.Client.Initialize
>>            ("smtp.gmail.com", Port => 465,
>>             Credential             => Auth'Unchecked_Access);
> 
> I succeed sending mail via gmail.com using port 587.
> 
> No useful further details on encryption - this was for the membership
> d/b for a small club, and it's in Python/sqlite.

GNUTLS and OpenSSL have ways to tell to use the system certificates. 
E.g. if your Python application uses GNUTLS it would call

    gnutls_certificate_set_x509_system_trust

and that should be enough to make successful handshaking afterwards.

>      self.server = smtplib.SMTP(host=self.server_details['host'],
>                                 port=self.server_details['port'])
>      self.server.ehlo()
>      self.server.starttls()

Here it switches transport to GNUTLS or OpenSSL and these perform TLS 
handshaking. The following commands run over encrypted channel.

But with the port 587 you should actually begin with TLS straight away. 
StartTLS is for servers which allow both secure and insecure 
connections. This is usually the port 465. If you are OK with no 
encryption you greet with HELO and then proceed with login. If you want 
a secure connection you greet with EHLO and then send StartTLS.

>      self.server.ehlo()
>      self.server.login\
>          (user=server_details['user'],
>           password=keyring.get_password\
>             ('u3a-email', server_details['user']))

This is very low-level. AWS design is far better, IMO.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

end of thread, other threads:[~2021-09-03 21:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 18:58 Attempt to send email using AWS results in Socket closed by peer Juan Rayas
2021-09-01 19:43 ` Dmitry A. Kazakov
2021-09-02 22:19   ` Randy Brukardt
2021-09-03  7:32     ` Dmitry A. Kazakov
2021-09-03  8:59       ` Doctor Who
2021-09-03 18:11         ` Juan Rayas
2021-09-03 18:31           ` Dmitry A. Kazakov
2021-09-03 19:33           ` Doctor Who
2021-09-03 20:29             ` Juan Rayas
2021-09-01 20:02 ` Dennis Lee Bieber
2021-09-02  3:29 ` Richard Iswara
2021-09-02  4:03 ` Doctor Who
2021-09-02 22:22   ` Randy Brukardt
2021-09-03 20:35 ` Simon Wright
2021-09-03 21:13   ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox