bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] More info; mailers?


From: Sergey Poznyakoff
Subject: Re: [bug-mailutils] More info; mailers?
Date: Fri, 20 Aug 2004 16:40:43 +0300

Hi Chris,

I have tested mailutils with mod_guile. It works just as
expected, except for a minor bug in the library[1]. Attached
is a sample script I have used. It reads and displays
contents of the given mailbox and then sends a simple message
using smtp: mailer. Please, test if it works for you. You will
have to modify variables my-mailbox and mu-mailer as well as 'From'
and 'To' addresses (lines 54-55).

Regards,
Sergey

[1] You have to always give second argument to mu-message-send
(see line 63).  

(define my-mailbox "/var/spool/mail/gray")
(set! %load-path (cons "/usr/share/mailutils" %load-path))
(use-modules (mailutils))

(display "<html><head><title>A Sample Scheme Page</title><head>
          <body>
          <h1>Hello from Guile!</h1>
            If you see this you successfully installed mod_guile.")
(display "<br>You have also installed ")
(display mu-package-string)
(let ((mbox (mu-mailbox-open my-mailbox "r")))
  (display "<br>Opening mailbox <code>")
  (display my-mailbox)
  (display "</code>: ")
  (cond 
   (mbox 
    (let ((count (mu-mailbox-messages-count mbox)))
      (display count)
      (display " message(s)")
      (display "<h2>Mailbox listing:</h2>") 
      (do ((n 1 (1+ n)))
          ((> n count) #f)
        (let ((msg (mu-mailbox-get-message mbox n)))
          (display "<h3>Message ")
          (display n)
          (display "</h3><p><pre>")
          (for-each
           (lambda (x)
             (display x)(display ": ")
             (display (mu-message-get-header msg x))
             (display "<br>"))   
           '("From" "To" "Subject" "Date"))
          (display "<p>") 
          (let ((port (mu-message-get-port msg "r")))
            (do ((line (read-line port) (read-line port)))
                ((eof-object? line) #f)
              (display line)
              (newline))
            (close-input-port port))
          (display "</pre>")))))
   (else  
    (display "FAILED"))))
(newline)

;; Now let's try to send something
(mu-register-format "smtp")
(set! mu-mailer "smtp://mirddin.farlep.net") 

(display "<h2>Sending message using ")
(display mu-mailer)
(display "</h3>")

(let ((mesg (mu-message-create)))
  (mu-message-set-header mesg "From" "address@hidden")
  (mu-message-set-header mesg "To" "address@hidden")
  (mu-message-set-header mesg "Subject" "Notification")
  (let ((port (mu-message-get-port mesg "w")))
    (display "This message has been sent using Apache/mod_guile/GNU mailutils"
             port)
    (newline port)
    (close-output-port port))
  (display "Result <code>")
  (display (mu-message-send mesg))
  (display "</code>"))

(display "          
          </body>
          </html>")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]