comp.lang.ada
 help / color / mirror / Atom feed
* send email
@ 2017-06-28  9:25 Distant Worlds
  2017-07-18  7:48 ` Björn Lundin
  0 siblings, 1 reply; 2+ messages in thread
From: Distant Worlds @ 2017-06-28  9:25 UTC (permalink / raw)


with Text_IO;
with AWS.POP;
with AWS.SMTP;
with AWS.SMTP.Client;
with Ada.Text_IO;


procedure Main is
	
   SMTP_Server : AWS.SMTP.Receiver;  
   Status : AWS.SMTP.Status;
   
begin 

   SMTP_Server := AWS.SMTP.Client.Initialize(Server_Name => "smtp.mail.com", 
                                             Port => 465, 
                                             Secure => True);
   
   AWS.SMTP.Client.Send(SMTP_Server,
                        From    => AWS.SMTP.E_Mail(Name => "", Address => ""),
                        To      => AWS.SMTP.E_Mail(Name => "", Address => ""),
                        Subject => "Subject",
                        Message => "Message",
                        Status  => Status);
   
   if not AWS.SMTP.Is_Ok (Status) then
      Ada.Text_IO.Put_Line ("Can't send message: " & AWS.SMTP.Status_Message (Status));
   end if;
                        
end Main;


/********************************************************************/

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

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

* Re: send email
  2017-06-28  9:25 send email Distant Worlds
@ 2017-07-18  7:48 ` Björn Lundin
  0 siblings, 0 replies; 2+ messages in thread
From: Björn Lundin @ 2017-07-18  7:48 UTC (permalink / raw)


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


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

end of thread, other threads:[~2017-07-18  7:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28  9:25 send email Distant Worlds
2017-07-18  7:48 ` Björn Lundin

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