mardi 19 janvier 2016

How to solve when received attached file are smaller then actual size in rails?

I am using Rails4. I am trying to send an email with attachment. My mail is working finely but the attachment file is not in proper size. I am sending a 64kb pdf file but when I receive a mail it shows 1kb. How can I solve this problem? My codes are below:

mailer.rv

 class RvMailer < ApplicationMailer

  default from: "info@example.com"

  def abc(contact)
    @contact = contact
     attachments["CRF.pdf"] = File.read("#{Rails.root}/public/attachment/CRF.pdf")
    mail(to: @contact.email, subject: 'Rupeevest')
  end

end

controller:

    def create_mail
    @contactabc = Contact.new(contact_params)
    if @contactabc.save
      RvMailer.abc(@contactabc).deliver
      redirect_to :back
    else
      render contact_path
    end
  end

  private
    def contact_params
       params.require(:contact).permit(:name,:email)

    end

email.yml

development:
  :address: smtp.gmail.com
  :port: 587
  :Domain: mail.google.com
  :authentication: plain
  :user_name: info@example.com
  :password: XXXXXXXXX
  :enable_starttls_auto: true 

Aucun commentaire:

Enregistrer un commentaire