From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: guile - sending emails Date: Mon, 20 Oct 2014 22:13:56 +0100 Message-ID: <20141020221356.78e4d4e0@bother.homenet> References: <54456DEB.2000401@konradmakowski.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1413839667 22605 80.91.229.3 (20 Oct 2014 21:14:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Oct 2014 21:14:27 +0000 (UTC) Cc: guile-user@gnu.org To: Konrad Makowski Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Oct 20 23:14:20 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XgKHR-00048b-U2 for guile-user@m.gmane.org; Mon, 20 Oct 2014 23:14:18 +0200 Original-Received: from localhost ([::1]:46870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgKHR-0001oo-GN for guile-user@m.gmane.org; Mon, 20 Oct 2014 17:14:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgKHC-0001jM-D0 for guile-user@gnu.org; Mon, 20 Oct 2014 17:14:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgKH5-0006NH-Un for guile-user@gnu.org; Mon, 20 Oct 2014 17:14:02 -0400 Original-Received: from smtpout1.wanadoo.co.uk ([80.12.242.29]:49844 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgKH5-0006Mc-Ok for guile-user@gnu.org; Mon, 20 Oct 2014 17:13:55 -0400 Original-Received: from bother.homenet ([95.146.108.85]) by mwinf5d07 with ME id 5ZDs1p0071qb5Bz03ZDsF0; Mon, 20 Oct 2014 23:13:53 +0200 X-ME-Helo: bother.homenet X-ME-Date: Mon, 20 Oct 2014 23:13:53 +0200 X-ME-IP: 95.146.108.85 Original-Received: from bother.homenet (localhost [127.0.0.1]) by bother.homenet (Postfix) with ESMTP id 6C0E68B9D4; Mon, 20 Oct 2014 22:13:56 +0100 (BST) In-Reply-To: <54456DEB.2000401@konradmakowski.pl> X-Mailer: Claws Mail 3.10.0 (GTK+ 2.24.24; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.12.242.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11586 Archived-At: On Mon, 20 Oct 2014 22:17:47 +0200 Konrad Makowski wrote: > How can i send emails from guile script? Is there any module for that > purpose? I know that there is mailutils but can't figure out how to > do that with it. Please, show me some examples. I use mailx for that together with guile-lib's (os process) module, mainly because I know what they do, I have used them before and they work. Here is part of a daemon script I use to broadcast a change of ip address to a list of recipients for internal purposes. It should be self-explanatory: there are various things defined elsewhere in the script. (define (send-ip ip changed) (let ([preamble (if changed "Changed: " "Reminder: ")]) (log (string-append preamble "sending " ip " to " (reduce (lambda (cur prev) (string-append prev " " cur)) "" to-mail-addr))) (let* ([res (apply run-with-pipe "w" "mailx" "-s" "IP" "-r" from-mail-addr to-mail-addr)] [pid (car res)] [output (cdr res)]) (put-string output (string-append preamble ip "\n")) (close-port output) ;; closing the pipe causes mailx to unblock and send (let ([ret (status:exit-val (cdr (waitpid pid)))]) (when (or (not ret) (not (= ret 0))) (log "Error invoking mailx"))))))