2016-01-15 27 views
8

मैं रेल 4.रेल 4, वसीयत और प्रकार का बंदर ईमेल

पिछले 3 वर्षों के लिए में एक ऐप्लिकेशन बनाने के लिए कोशिश कर रहा हूँ, मैं यह पता लगाने के लिए संघर्ष कर रहा है वसीयत/omniauth (मैं अभी भी पाने के लिए कोशिश कर रहा हूँ यह काम करने के लिए)।

मुख्य समस्याओं से अलग कदम उठाने के दौरान, मैं इस माध्यम से रहने की इच्छा को खोजने और खोजने के लिए, मैंने मंड्रिल के साथ ईमेल सेट करने का प्रयास किया है।

मैंने पाया इस ट्यूटोरियल है, जो मैं के साथ पालन करने के लिए कोशिश कर रहा हूँ: https://nvisium.com/blog/2014/10/08/mandrill-devise-and-mailchimp-templates/

मैं एक मेलर mandrill_devise_mailer.rb कहा जाता है

class MandrillDeviseMailer < Devise::Mailer 

    def confirmation_instructions(record, token, opts={}) 
    # code to be added here later 
    end 

    def reset_password_instructions(record, token, opts={}) 
    options = { 
     :subject => "Reset your password", 
     :email => record.email, 
     :global_merge_vars => [ 
     { 
      name: "password_reset_link", 
      # content: "http://www.example.com/users/password/edit?reset_password_token=#{token}" 
      content: "http://www.cr.com/users/password/edit?reset_password_token=#{token}" 

     }, 

     { 
      name: "PASSWORD_RESET_REQUEST_FROM", 
      content: record.full_name 
     } 
     ], 
     :template => "Forgot Password" 
    } 
    mandrill_send options 
    end 

    def unlock_instructions(record, token, opts={}) 
    # code to be added here later 
    end 

    def mandrill_send(opts={}) 
    message = { 
     :subject=> "#{opts[:subject]}", 
     :from_name=> "Reset Instructions", 
     # :from_email=>"[email protected]", 
     :from_email=>["PROD_WELCOME"], 
     :to=> 
      [{"name"=>"#{opts[:full_name]}", 
       "email"=>"#{opts[:email]}", 
       "type"=>"to"}], 
     :global_merge_vars => opts[:global_merge_vars] 
     } 
    sending = MANDRILL.messages.send_template opts[:template], [], message 
    rescue Mandrill::Error => e 
     Rails.logger.debug("#{e.class}: #{e.message}") 
     raise 
    end 
end 

ऊपर और के बीच मतभेद है कि वे क्या ट्यूटोरियल में किया है कर रहे हैं:

अपने मेल चिम्प प्रकार का बंदर टेम्पलेट में, मेरे पास है:

<a href="*|password_reset_link|*">Change my password </a> 

जब मुझे निर्देशों को रीसेट करने के लिए ईमेल प्राप्त होता है, तो मुझे परिवर्तन पासवर्ड फ़ॉर्म के लिए एक रेखांकित लिंक मिलता है, जो कहता है 'इसके आगे मेरा पासवर्ड बदलें। मैं चाहता हूं कि 'मेरा पासवर्ड बदलें लेबल बनें जो लिंक टेक्स्ट को छुपाता है'।

क्या कोई देख सकता है कि मैंने क्या गलत किया है?

+0

है आपका ': from_email'' [ "PROD_WELCOME"] 'जो करने के लिए एक ईमेल पता तरह नहीं दिखता है पर सेट है मुझे। – VNO

+0

धन्यवाद - एनएनवी को ईमेल भेजने के लिए सेट किया गया है, लेकिन यह परिवर्तनीय – Mel

+0

में खींचने के बजाए * || * के बीच शब्दों को प्रिंट करता है, हो सकता है कि आप हैंडलबार्स का उपयोग अपनी डिफ़ॉल्ट विलय भाषा के रूप में कर रहे हों? सेटिंग्स के तहत अपने मंड्रिल [विकल्प भेजना] (https://mandrillapp.com/settings/sending- विकल्प) पर जाएं और जांचें कि क्या आपके पास सही विलय भाषा सक्षम है या नहीं। –

उत्तर

-2

यहाँ कैसे मैं कस्टम DeviseMailer बनाया

class MyDeviseMailer < Devise::Mailer 
    default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views 

    def reset_password_instructions(record, token, opts={}) 
    opts['from_email'] = "[email protected]" 
    opts['from_name'] = "Password Reset" 
    #Rails.logger.mail.info "reset_password_instructions #{record.to_json} \n #{token.to_json} \n #{opts.to_json}" 
    super 
    end 

end 

https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer और Add dynamic value in devise email subject

+0

हाय दिमित्री के साथ समस्या का समाधान नहीं करता है, यह ' टी देखो जैसे आप Mailchimp/mandrill का उपयोग करने की कोशिश कर रहे हैं। फिर भी धन्यवाद। – Mel

+0

मंड्रिल एपीआई को उन opts ['from_email'] की आवश्यकता होती है और ['from_name'] पैरा को चुनती है। मैंने कस्टम डिलीवरी क्लास प्रति http://www.alanverga.com/blog/2014/01/03/custom-rails-mailer-and-mandrill और https://robots.thoughtbot.com/how-to-send- ट्रांजैक्शनल-ईमेल-से-रेल-साथ-मैंडरिल –

+0

लेकिन मेरे पास ये विकल्प भी मेरी फ़ाइल हैं। मेरी समस्या यह है कि लिंक लिंक के रूप में प्रारूपित नहीं होते हैं जिस तरह से मैंने उन्हें व्यक्त किया है।इसके बजाए, लिंक टैग के रूप में इसके आगे के लिंक के लेबल के साथ एक टैग दिखाई देने के अंदर दिखाई देता है। – Mel

संबंधित मुद्दे