net/sendmail: delay executable search until needed
This commit is contained in:
parent
f378aa1b7a
commit
ba661e009b
|
@ -1,4 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
(require racket/promise)
|
||||||
|
|
||||||
(provide send-mail-message/port send-mail-message)
|
(provide send-mail-message/port send-mail-message)
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
'("/usr/sbin" "/sbin" "/usr/local/sbin" "/usr/lib"))
|
'("/usr/sbin" "/sbin" "/usr/local/sbin" "/usr/lib"))
|
||||||
|
|
||||||
(define sendmail-program-file
|
(define sendmail-program-file
|
||||||
|
(delay
|
||||||
(let ([exe (case (system-type)
|
(let ([exe (case (system-type)
|
||||||
[(windows) "sendmail.exe"]
|
[(windows) "sendmail.exe"]
|
||||||
[else "sendmail"])])
|
[else "sendmail"])])
|
||||||
|
@ -19,7 +21,7 @@
|
||||||
(raise (make-exn:fail:unsupported
|
(raise (make-exn:fail:unsupported
|
||||||
(format "unable to find a sendmail executable in ~s"
|
(format "unable to find a sendmail executable in ~s"
|
||||||
sendmail-search-path)
|
sendmail-search-path)
|
||||||
(current-continuation-marks))))))
|
(current-continuation-marks)))))))
|
||||||
|
|
||||||
;; Main implementation, returns a port
|
;; Main implementation, returns a port
|
||||||
(define (send-mail-core who sender subject TOs CCs BCCs headers)
|
(define (send-mail-core who sender subject TOs CCs BCCs headers)
|
||||||
|
@ -31,7 +33,7 @@
|
||||||
(error who "no mail recipients were specified"))
|
(error who "no mail recipients were specified"))
|
||||||
(define-values [p pout pin perr]
|
(define-values [p pout pin perr]
|
||||||
;; use -i, so "." lines are not a problem
|
;; use -i, so "." lines are not a problem
|
||||||
(apply subprocess #f #f #f sendmail-program-file "-i" all-recipients))
|
(apply subprocess #f #f #f (force sendmail-program-file) "-i" all-recipients))
|
||||||
(close-input-port pout)
|
(close-input-port pout)
|
||||||
(close-input-port perr)
|
(close-input-port perr)
|
||||||
(port-count-lines! pin)
|
(port-count-lines! pin)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user