2017-04-11 3 views
0

Mailgunで2つのファイルを使用してメッセージを送信しています。彼らは以下のとおりです。最初のもののためのコードがあるRubyを使って複数の平文メールをMailgunで送ることができません

email_sender.rb 
message_text.rb 

require './message_text.rb' 

fromLabel = "Email Guy" 
fromAddress = "[email protected]*****.com" 
toAddress = "[email protected]*****.net" 
subject = "An Invitation" 

cmd = "curl -s --user 'api:key-*****' https://api.mailgun.net/v3/mail.*****.com/messages -F from='" + fromLabel + " <" + fromAddress + ">' -F to='" +toAddress + "' -F subject='" + subject + "' -F text='" + $message + "'" 

wasGood = system (cmd) 

秒ファイルのコードは次のとおりです。

$message = "Line One Text." 
+ "\n" + "\n" + "And Line Two Text!" 

私は、電子メール、メッセージを送信テストテストアカウントの受信トレイに到着すると、次のようになります。

Line One Text. 

答えて

2

あなたはruby -wでコードを実行すると、それは次のとおりです。警告を有効にすると、それは警告する:warning: possibly useless use of + in void contextを、応じて行番号と、を指す:ルビーの丁寧な方法です

$message = "Line One Text." 
+ "\n" + "\n" + "And Line Two Text!" 

「まあ、構文エラーではありませんが、私には意味がありません」 試してみてください

$message = "Line One Text. 

And Line Two Text!" # or: "Line One Text.\n\nAnd Line Two Text!" 
0

だから私はすべてを1行に入れて動作させました。

$message = "Line One Text!" + "\n" + "\n" + "Line Two Text!" 
関連する問題