diff --git a/R/conf.R b/R/conf.R index 57d9e21..e53002b 100644 --- a/R/conf.R +++ b/R/conf.R @@ -138,7 +138,7 @@ checkConfElements = function(cluster.functions, mail.to, mail.from, if (!missing(mail.error)) assertChoice(mail.error, mail.choices) if (!missing(mail.control)) - assertList(mail.control) + assert( is.function(mail.control) || is.list(mail.control) ) if (!missing(db.driver)) assertString(db.driver) if (!missing(db.options)) diff --git a/R/sendMail.R b/R/sendMail.R index 832e475..8937ded 100644 --- a/R/sendMail.R +++ b/R/sendMail.R @@ -34,6 +34,11 @@ sendMail = function(reg, ids, result.str, extra.msg = "", } # if a mail problem occurs, we only warn but do not terminate + if( is.function(conf$mail.control) ){ # use email function if nessecary + sendmail <- function(from, to, subj, msg, ...){ + conf$mail.control(status = condition, from = from, to = to, subject = subj, body = msg, registry = reg, ids = ids) + } + } ok = try (sendmail(conf$mail.from, conf$mail.to, subj, msg, control = conf$mail.control)) if (is.error(ok)) { warningf("Could not send mail to signal condition '%s'!\nFrom: %s\nTo: %s\nControl: %s\nError message: %s",