From: Chris Vine <chris@cvine.freeserve.co.uk>
To: Konrad Makowski <poczta@konradmakowski.pl>
Cc: guile-user@gnu.org
Subject: Re: guile - sending emails
Date: Mon, 20 Oct 2014 22:13:56 +0100 [thread overview]
Message-ID: <20141020221356.78e4d4e0@bother.homenet> (raw)
In-Reply-To: <54456DEB.2000401@konradmakowski.pl>
On Mon, 20 Oct 2014 22:17:47 +0200
Konrad Makowski <poczta@konradmakowski.pl> 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"))))))
next prev parent reply other threads:[~2014-10-20 21:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 20:17 guile - sending emails Konrad Makowski
2014-10-20 21:13 ` Chris Vine [this message]
2014-10-20 23:13 ` Mike Gran
2014-10-30 10:30 ` ftp uploading files Konrad Makowski
2014-10-30 12:59 ` Mike Gran
2014-10-21 3:30 ` guile - sending emails Nala Ginrut
2014-10-23 11:15 ` Konrad Makowski
2014-10-23 18:04 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141020221356.78e4d4e0@bother.homenet \
--to=chris@cvine.freeserve.co.uk \
--cc=guile-user@gnu.org \
--cc=poczta@konradmakowski.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).