comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: send email
Date: Tue, 18 Jul 2017 09:48:26 +0200
Date: 2017-07-18T09:48:26+02:00	[thread overview]
Message-ID: <okke8u$3sg$1@dont-email.me> (raw)
In-Reply-To: <aede705a-3a5d-4891-87e3-5d86563ee86c@googlegroups.com>

On 2017-06-28 11:25, Distant Worlds wrote:

> 
> 
> /********************************************************************/
> 
> raised PROGRAM_ERROR : finalize/adjust raised exception
>    
> /********************************************************************/
>      
>      CentOS 6.9 Ada GNAT 2017
>        
>        
>>> :((
>        
> 

I got this running fine seding mails from Amazon.
I _think_ you need a Credential parameter in the Initialize if you say
Secure => True
And I could not point out the path to the cert, had to make that current
directory. But that may have changed now.


  procedure Mail_Saldo(Saldo, Old : Balances.Balance_Type) is
     T       : Calendar2.Time_Type := Calendar2.Clock;
     Subject : constant String             := "BetBot Saldo Report";
     use AWS;
     SMTP_Server_Name : constant String :=
     "email-smtp.eu-west-1.amazonaws.com";
     Status : SMTP.Status;
  begin

Ada.Directories.Set_Directory(Ada.Environment_Variables.Value("BOT_CONFIG")
& "/sslcert");
    declare
      Auth : aliased constant SMTP.Authentication.Plain.Credential :=
                                SMTP.Authentication.Plain.Initialize
("AKESJZDQQ2DDNB58SKQ",
                                              "SOME scrabled string");
      SMTP_Server : SMTP.Receiver := SMTP.Client.Initialize
                                  (SMTP_Server_Name,
                                   Port       => 2465,
                                   Secure     => True,
                                   Credential => Auth'Unchecked_Access);
      use Ada.Characters.Latin_1;
      Today     : Fixed_Type := Saldo.Balance + abs(Saldo.Exposure);
      Yesterday : Fixed_Type := Old.Balance + abs(Old.Exposure);
      Msg : constant String :=
          "some MSG sent from: " & GNAT.Sockets.Host_Name ;

      Receivers : constant SMTP.Recipients :=  (
                An array of the receivers
                );
    begin
      SMTP.Client.Send(Server  => SMTP_Server,
                       From    => SMTP.E_Mail ("someone",
"someone@someone.com"),
                       To      => Receivers,
                       Subject => Subject,
                       Message => Msg,
                       Status  => Status);
    end;
    if not SMTP.Is_Ok (Status) then
      Log (Me & "Mail_Saldo", "Can't send message: " &
SMTP.Status_Message (Status));
    end if;
  end Mail_Saldo;



-- 
--
Björn


      reply	other threads:[~2017-07-18  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28  9:25 send email Distant Worlds
2017-07-18  7:48 ` Björn Lundin [this message]
replies disabled

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