vignettes/files/examples/mailgun.R

emails <- data.frame(
  from = character(0),
  time = character(0),
  subject = character(0)
)

#* @post /mail
function(body) {
  emails <<- rbind(emails, data.frame(
    from = body$from,
    time = date(),
    subject = body$subject
  ))
  Next
}

#* @get /tail
function() {
  tail(emails[,-1], n=5)
}

Try the plumber2 package in your browser

Any scripts or data that you put into this service are public.

plumber2 documentation built on Jan. 20, 2026, 5:06 p.m.