2016-07-08 10 views
4

私のShinyアプリケーションからメールを送信しようとしています。私はメールのアドレス、件名、本文を入力するためのテキスト入力ボックスを作成しました。テキスト入力ボックスに自分の入力が1つのメールIDであるとき、アプリはメールを送信します。 2番目の電子メールIDを追加すると失敗します。しかし、私がRStudioから光っているアプリではなく同じコードを実行しようとしたときに、私は電子メールを送信することができます。どのように私のtextInputは、mailRがメールを送信するように電子メールIDを正しく解析するのですか?mailR:光沢のある複数のアドレスにメールを送信

私の現在のコード:

library(shiny) 
library(mailR) 

ui =fluidPage(
     fluidRow(
     div(id = "login", 
      wellPanel(title = "Mail your report", 
       textInput("to", label = "To:", placeholder = "To:"), 
       textInput("sub","Subject:"), 
       textInput("msg","Message:"), 
       actionButton("mailButton",label = "Send mail") 
       ) 
      )) 
) 
server = function(input, output, session) { 
observeEvent(input$mailButton,{ 
       isolate({ 
        send.mail(from = "[email protected]", 
        to = input$to, 
        subject = input$sub, 
        body = input$msg, 
        smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "[email protected]", passwd = "mypasword", ssl = TRUE), 
        authenticate = TRUE, 
        html = TRUE, 
        send = TRUE) 
       }) 
      }) 

     } 

runApp(list(ui = ui, server = server)) 

私は、次のエラーを取得しています:

Listening on http://127.0.0.1:3499 
javax.mail.internet.AddressException: Illegal address in string ``[email protected], [email protected]'' 
    at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:114) 
NULL 
Warning: Error in : AddressException (Java): Illegal address 
Stack trace (innermost first): 
    83: <Anonymous> 
    82: signalCondition 
    81: doWithOneRestart 
    80: withOneRestart 
    79: withRestarts 
    78: message 
    77: value[[3L]] 
    76: tryCatchOne 
    75: tryCatchList 
    74: tryCatch 
    73: .jTryCatch 
    72: .valid.email 
    71: send.mail 
    64: isolate 
    63: observeEventHandler [#3] 
    1: runApp 
ERROR: [on_request_read] connection reset by peer 

答えて

1

はこれを試してみてください、電子メールの間の区切りと仮定すると、セミコロンです:

to = unlist(strsplit(input$to, ";", fixed = TRUE)) 
+0

ありがとうございました、この解決策が働いた。 – Apricot

関連する問題