Here is the Shiny email sender I wrote to test the sendmailR
package in a Shiny app. On a Linux platform, I have not configured anything and the app perfectly works. The user types the body of the message in a text area generated and handled by the shinyAce
package.
ui.R
shinyUI(pageWithSidebar(
headerPanel("Email sender"),
sidebarPanel(
textInput("from", "From:", value="from@gmail.com"),
textInput("to", "To:", value="to@gmail.com"),
textInput("subject", "Subject:", value=""),
actionButton("send", "Send mail")
),
mainPanel(
aceEditor("message", value="write message here")
)
))
server.R
library(shinyAce)
library(sendmailR)
shinyServer(function(input, output, session) {
observe({
if(is.null(input$send) || input$send==0) return(NULL)
from <- isolate(input$from)
to <- isolate(input$to)
subject <- isolate(input$subject)
msg <- isolate(input$message)
sendmail(from, to, subject, msg)
})
})