From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, WEIRD_QUOTING autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,baeec22380c7d63d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-18 08:45:22 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!surfnet.nl!isdnet!enst!enst.fr!not-for-mail From: "M. A. Alves" Newsgroups: comp.lang.ada Subject: Re: Looking for package Email Date: Mon, 18 Jun 2001 17:44:23 +0100 (WEST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: avanie.enst.fr 992879121 91499 137.194.161.2 (18 Jun 2001 15:45:21 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 18 Jun 2001 15:45:21 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: X-Sender: maa@borba.ncc.up.pt In-Reply-To: <3B2E17E2.4755E820@raytheon.com> Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:8848 Date: 2001-06-18T17:44:23+01:00 > [1] On many systems, generate your mail message as a text file & use an > OS call to run your mail utility program to send it. Doing that now. Using the "mail" utility on a Linux system, in a call to the POSIX "system" function. Simplest way, I think. It works---as long as the system settings associated with the "mail" utility are ok of course. package Mail is Error: exception; procedure Send_Message( To: String; CC: String := ""; BC: String := ""; Reply_To: String := ""; Subject: String := ""; Text: String := ""); end Mail; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_Io; use Ada.Text_Io; with Posix; use Posix; package body Mail is procedure Send_Message( To: String; CC: String := ""; BC: String := ""; Reply_To: String := ""; Subject: String := ""; Text: String := "") is Tempfilename: String := "/tmp/a_temporary_mail_message_text_file"; Tempfile: File_Type; U: Unbounded_String; R: Integer; begin Create(Tempfile, Out_File, Tempfilename); Put(Tempfile, Text); Append(U, "mail"); if CC /= "" then Append(U, " -c" & CC); end if; if BC /= "" then Append(U, " -b" & BC); end if; if Subject /= "" then Append(U, " -s """ & Subject & """"); end if; Append(U, " " & To & " < " & Tempfilename); R := System(To_String(U)); Delete(Tempfile); if R = 127 or R = -1 then raise Error; end if; end Send_Message; end Mail; package Posix is function System(Command: String) return Integer; end Posix; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; package body Posix is function C_System(Command: chars_ptr) return int; pragma Import(C, C_System, "system"); function System(Command: String) return Integer is C_Command : aliased char_array := To_C(Command); begin return(Integer(C_System(To_Chars_Ptr(C_Command'Unrestricted_Access)))); end System; end Posix; -- , M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121 A M A D O Rua Campo Alegre, 823 fax 351+226003654 A L V E S P-4150 PORTO, Portugal mob 351+939354002