2017-12-30 53 views
-1

Linuxの外部コマンド "mail"を使用してscalaから電子メールを送信したいと思います。SCALA: "subject"を含む外部コマンド "mail"

scala> val email="[email protected]" 
    email: String = [email protected] 
scala> val result = "echo ECCO" #| s"mail -s ciao_bello $email " ! 
warning: there was one feature warning; re-run with -feature for details 
result: Int = 0 

を送ったが、件名OK SENT

:チャオは

scala> val subject="ciao bello !" 
    subject: String = ciao bello ! 
scala> val result = "echo BODY" #| s"mail -s $subject $email " ! 
warning: there was one feature warning; re-run with -feature for details 
rewrite: excessive recursion (max 50), ruleset Canonify2 
result: Int = 0 

SENT コマンド実行の作品は、ちょうど私が件名の文字列、ここではいくつかのtentativesを設定するトラブルを持っていますしかし、件名: "ciao"

scala> val subject= "\"ciao bello !\"" 
    subject: String = "ciao bello !" 
scala> val result = "echo BODY" #| s"mail -s $subject $email " ! 
warning: there was one feature warning; re-run with -feature for details 
!"... Unbalanced '"' 
result: Int = 0 

は、私は言葉よりも多くを含む被験者に対処するにはどうすればよい

scala> val result = "echo BODY" #| s"mail -s \"ciao bello\" $email " ! 
<console>:10: error: value ciao is not a member of `enter code here`scala.sys.process.ProcessBuilder 
     val result = "echo BODY" #| s"mail -s \"ciao bello\" $email " !            
<console>:10: error: not found: value bello 
     val result = "echo BODY" #| s"mail -s \"ciao bello\" $email " ! 

を送信されませんか?

scala> val subject="\"ciao bello !\"" 
subject: String = "ciao bello !" 

scala> val result = Seq("sh", "-c", s"echo BODY | mail -s $subject $email") ! 
warning: there was one feature warning; re-run with -feature for details 
result: Int = 0 

おかげと歓声を:

+0

私は主にコードの書式を改善しました。 – zx485

答えて

0

いくつかの敗者は、電子メールが正しく送信された前に、私の解決策が、ただの調整を行いました!

関連する問題