私のローカル開発環境でActionMailerを使用して電子メールを送信しようとしています。添付ファイルを除いてすべて正常に動作しています。Rails 5 Action Mailer jpgが正しく送信されない
次のコードブロックでは、サイズが6,19KBの電子メール "Testbild.jpg"にJPGファイルを添付します。ただし、受信者は、同じ名前のファイルが96バイトのサイズの電子メールを表示します。
def welcome_email(user)
@user = user
@url = 'http://example.com/login'
attachments['Testbild.jpg'] = File.read("#{Rails.root}/public/images/Testbild.jpg")
mail(to: @user.kontakt.email, subject: 'Welcome to My Awesome Site')
end
は、ここで私が受信したファイルの96のバイトがちょうど私のソースファイルの最初の96のバイトと同じであることが判明
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3001 }
config.action_mailer.smtp_settings = {
user_name: "[email protected]",
password: "************",
domain: "xclirion.de",
authentication: :plain,
address: "smtp.xclirion.de",
openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE,
enable_starttls_auto: true,
port: 587
}
development.rbに私actionmailerのコンフィグあります。残りは失われているようだ。
ここで何が問題になるのですか? RoRにファイル全体を強制的に送信させるにはどうすればいいですか?
この 'attachments.inline [ 'Testbild.jpg']を試してみてください= File.read("#Rails.root} /公共/画像/ Testbild .jpg ")' – hgsongra