* guile - sending emails
@ 2014-10-20 20:17 Konrad Makowski
2014-10-20 21:13 ` Chris Vine
2014-10-21 3:30 ` guile - sending emails Nala Ginrut
0 siblings, 2 replies; 8+ messages in thread
From: Konrad Makowski @ 2014-10-20 20:17 UTC (permalink / raw
To: guile-user
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.
--
Konrad
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guile - sending emails
2014-10-20 20:17 guile - sending emails Konrad Makowski
@ 2014-10-20 21:13 ` Chris Vine
2014-10-20 23:13 ` Mike Gran
2014-10-21 3:30 ` guile - sending emails Nala Ginrut
1 sibling, 1 reply; 8+ messages in thread
From: Chris Vine @ 2014-10-20 21:13 UTC (permalink / raw
To: Konrad Makowski; +Cc: guile-user
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"))))))
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guile - sending emails
2014-10-20 21:13 ` Chris Vine
@ 2014-10-20 23:13 ` Mike Gran
2014-10-30 10:30 ` ftp uploading files Konrad Makowski
0 siblings, 1 reply; 8+ messages in thread
From: Mike Gran @ 2014-10-20 23:13 UTC (permalink / raw
To: Chris Vine, Konrad Makowski; +Cc: guile-user@gnu.org
> On Monday, October 20, 2014 2:14 PM, Chris Vine <chris@cvine.freeserve.co.uk> wrote:
> > 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've never actually looked at GNU Mailutils before, so I didn't
know it has a scheme interface. Sweet. Has anyone been using it?
Just for fun, I added the missing options to guile-curl that would
allow one to send an e-mail. If one checked out the very latest
git at ...
https://github.com/spk121/guile-curl
...one could do something like the following. But, that is a bit
crap. A proper library would handle the bookkeeping of the
many names, addresses, and dates appear multiple times in
SMTP headers.
Regards,
Mike Gran
---
(use-modules (curl))
(setlocale LC_ALL "")
(define data-port
(open-input-string
(string-append
"From: \"John Doe\" <jdoe@yahoo.com>\r\n"
"To: \"John Smith\" <jsmith@nobody.com>\r\n"
"Subject: Test Message\r\n"
"\r\n"
"This is the body of my mesage.\r\n")))
(define handle (curl-easy-init))
(curl-easy-setopt handle 'url "smtps://smtp.mail.yahoo.com:465")
(curl-easy-setopt handle 'verbose #t)
(curl-easy-setopt handle 'use-ssl CURLUSESSL_ALL)
(curl-easy-setopt handle 'username "jdoe@yahoo.com")
(curl-easy-setopt handle 'password "xxxxx")
(curl-easy-setopt handle 'mail-from "jdoe@yahoo.com")
(curl-easy-setopt handle 'mail-rcpt '("jsmith@nobody.com"))
(curl-easy-setopt handle 'readdata data-port)
(curl-easy-perform handle)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guile - sending emails
2014-10-20 20:17 guile - sending emails Konrad Makowski
2014-10-20 21:13 ` Chris Vine
@ 2014-10-21 3:30 ` Nala Ginrut
2014-10-23 11:15 ` Konrad Makowski
1 sibling, 1 reply; 8+ messages in thread
From: Nala Ginrut @ 2014-10-21 3:30 UTC (permalink / raw
To: Konrad Makowski; +Cc: Guile User
I don't know if there's any lib for sending mails, but I do have a
similar module in Artanis:
https://github.com/NalaGinrut/artanis/blob/wip-sql-mapping/artanis/sendmail.scm
It's naive and simple since it's not a significant part for a
web-framework at present, but maybe enough to inspire someone to write
a completed standalone one. ;-)
-----------------------------------------Usage-------------------------------------------------
(define sender (make-simple-mail-sender "a@a.com" "b@b.com" #:sender
"/usr/sbin/sendmail"))
(send-the-mail (sender "hello!" #:subject "test"))
-----------------------------------------end-----------------------------------------------------
It's a buggy module, so please don't ask me why, if you can't send out
the mail...and please checkout your sendmail config first.
The example above works for me anyway.
Happy hacking!
On Tue, Oct 21, 2014 at 4:17 AM, 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.
>
> --
> Konrad
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guile - sending emails
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
0 siblings, 1 reply; 8+ messages in thread
From: Konrad Makowski @ 2014-10-23 11:15 UTC (permalink / raw
To: Guile User
I use msmtp for my needs.
(define (send-email)
(let ((port (open-pipe* OPEN_BOTH "msmtp" SMTP_MAIL_TO_SECRETARY)))
(display (smtp-body) port)
(close-pipe port)))
Works great.
Konrad
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guile - sending emails
2014-10-23 11:15 ` Konrad Makowski
@ 2014-10-23 18:04 ` Mark H Weaver
0 siblings, 0 replies; 8+ messages in thread
From: Mark H Weaver @ 2014-10-23 18:04 UTC (permalink / raw
To: Konrad Makowski; +Cc: Guile User
Konrad Makowski <poczta@konradmakowski.pl> writes:
> I use msmtp for my needs.
>
> (define (send-email)
> (let ((port (open-pipe* OPEN_BOTH "msmtp" SMTP_MAIL_TO_SECRETARY)))
> (display (smtp-body) port)
> (close-pipe port)))
You should use OPEN_WRITE instead of OPEN_BOTH here, but otherwise it
looks good to me.
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* ftp uploading files
2014-10-20 23:13 ` Mike Gran
@ 2014-10-30 10:30 ` Konrad Makowski
2014-10-30 12:59 ` Mike Gran
0 siblings, 1 reply; 8+ messages in thread
From: Konrad Makowski @ 2014-10-30 10:30 UTC (permalink / raw
To: Mike Gran; +Cc: guile-user@gnu.org
Hello,
Can you give an example of uploading files to an ftp server with guile-curl?
konrad
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ftp uploading files
2014-10-30 10:30 ` ftp uploading files Konrad Makowski
@ 2014-10-30 12:59 ` Mike Gran
0 siblings, 0 replies; 8+ messages in thread
From: Mike Gran @ 2014-10-30 12:59 UTC (permalink / raw
To: Konrad Makowski; +Cc: guile-user@gnu.org
I've never actually tried it, and I don't have any access to a box where I can
try it right now.
You'd probably need to use the git release, which has the 'readdata'
option which isn't in the last official release.
And then you'd probably do something like this.
(define handle (curl-easy-init))
(curl-easy-setopt 'url "ftp://hostname")
(curl-easy-setopt 'username "username")
(curl-easy-setopt 'password "password")
(curl-easy-setopt 'readdata (open-file-port "filename"))
(curl-easy-perform handle)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-10-30 12:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-20 20:17 guile - sending emails Konrad Makowski
2014-10-20 21:13 ` Chris Vine
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
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).