Page MenuHomeDevCentral
Paste P184

newmail
ActivePublic

Authored by dereckson on Apr 1 2016, 20:14.
Referenced Files
F28484: newmail
Apr 1 2016, 20:14
Subscribers
None
#!/usr/bin/env tclsh8.5
#Checks if there is a new mail in Maildir folders
#
# Helper methods
#
#Gets maildir directory
proc get_maildir {} {
global env
if [info exists env(MAILDIR)] {
return $env(MAILDIR)
}
return $env(HOME)/Maildir
}
#Return "s" when amount needs a plural
proc s {amount} { if {$amount >= 2} {return "s"} }
#
# Procedural code
#
#Checks if Maildir exists
if [file exists [set maildir [get_maildir]]] {
#Yes, check new mails
set nb [llength [glob -nocomplain -directory $maildir/new *]]
if {$nb > 0} {
puts ""
puts "*** You have $nb new mail[s $nb]"
puts ""
}
} {
#No, ask to create it
puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
puts " You don't have setup your mail delivery."
puts ""
puts " Please run the following command:"
puts " /var/qmail/bin/maildirmake $maildir"
puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
}

Event Timeline

dereckson changed the title of this paste from untitled to newmail.
dereckson updated the paste's language from autodetect to tcl.
dereckson added a project: Grip migration.