Add support for full email addresses.
This commit is contained in:
parent
8c436f6910
commit
7d1101657f
1 changed files with 26 additions and 12 deletions
|
@ -39,6 +39,7 @@
|
||||||
(chicken base)
|
(chicken base)
|
||||||
(chicken keyword)
|
(chicken keyword)
|
||||||
(chicken string)
|
(chicken string)
|
||||||
|
(chicken irregex)
|
||||||
util-io
|
util-io
|
||||||
util-utf8
|
util-utf8
|
||||||
util-string
|
util-string
|
||||||
|
@ -61,6 +62,14 @@ sent to the address stored within.")
|
||||||
"?=")
|
"?=")
|
||||||
subj))
|
subj))
|
||||||
|
|
||||||
|
;; Extracts only usernam@domain from given full RFC email address
|
||||||
|
(define (extract-email-email str)
|
||||||
|
(let* ((irr (irregex "(?:\"?([^\"]*)\"?\\s)?(?:<?(.+@[^>]+)>?)"))
|
||||||
|
(em (irregex-match irr str))
|
||||||
|
(name (irregex-match-substring em 1))
|
||||||
|
(email (irregex-match-substring em 2)))
|
||||||
|
email))
|
||||||
|
|
||||||
;; Sends an email using the UNIX mail(1) utility.
|
;; Sends an email using the UNIX mail(1) utility.
|
||||||
(define*/doc (send-mail body-lines
|
(define*/doc (send-mail body-lines
|
||||||
#:from (from #f)
|
#:from (from #f)
|
||||||
|
@ -83,17 +92,22 @@ Sends email using mail(1) command. The arguments ```#:to``` and
|
||||||
tos))
|
tos))
|
||||||
(header-args
|
(header-args
|
||||||
(flatten
|
(flatten
|
||||||
(map
|
(append
|
||||||
(lambda (h) (list "-a" h))
|
(if from (list (sprintf "From: ~A" from)) '())
|
||||||
headers))))
|
(map
|
||||||
(apply process-send/recv
|
(lambda (h) (list "-a" h))
|
||||||
"mail"
|
headers)))))
|
||||||
(append (if from
|
(let ((from-email (if from
|
||||||
(list "-r" from)
|
(extract-email-email from)
|
||||||
'())
|
#f)))
|
||||||
(list "-s" (encode-subject subject))
|
(apply process-send/recv
|
||||||
real-tos
|
"mail"
|
||||||
header-args)
|
(append (if from
|
||||||
body-lines)))
|
(list "-r" from-email)
|
||||||
|
'())
|
||||||
|
(list "-s" (encode-subject subject))
|
||||||
|
real-tos
|
||||||
|
header-args)
|
||||||
|
body-lines))))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue