0
votes

I am trying to send a mail using smtp method whose configration i had done in development.rb file,here it is

    Rails.application.configure do
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
       address:              'smtp.gmail.com',
       port:                 587,
       domain:               'example.com',
       user_name:            '[email protected]',
       password:             xxxxxxxx,
       authentication:       'plain',
       enable_starttls_auto: true  
    }

Here is the UserMailer which is present under the mailers folder, here i am getting the parameters value from a controller and parameter is assigned to a varible ,so that it can be available to the view UserMailer.rb

    class UserMailer < ApplicationMailer
        default from: '[email protected]'
        layout 'mailer'
        def conference_result(email,proposal,acknowledgement,positive,negative,chart)
            @email = email
            @proposal = proposal
            @acknowledgement = acknowledgement
            @positive = positive
            @negative = negative
            @chart = chart
            mail(to: @email , subject: 'Result for Your conference meeting' , content_type: "text/html")
        end
    end

Here is the content which i want to deliver in the mail, mailer.html.erb

    <body>
        <%= yield %>
            <h3 class="text-center" id="proposalhead">Proposal</h3>
            <div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:10px;" class="text-center">
                <%= @proposal %>
            </div>
            <h3 class="text-center hidden" id ="acknowledgementhead">Acknowledgement</h3>
            <div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:20px;margin-bottom:20px;" id ="Acknowledgement" class="text-center">
                <%= @acknowledgement %>
            </div>
            <h3 class="text-center hidden" id ="positivehead">Positive</h3>
            <div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:10px;" id ="Positive" class="text-center">
                <%= @positive %>
            </div>
            <h3 class="text-center hidden" id ="negativehead">Negative</h3>
            <div style="border:1px solid rgba(0,0,0,0.3);background-color: rgba(255,255,255,0.1);margin-top:10px;margin-bottom:20px" id = "Negative" class="text-center">
                <%= @negative %>
            </div>
            <div id="chart_div" style="width:100%;margin-bottom: 15px;margin-top:15px;" class="text-center">
                <%= @chart %>
            </div>      
      </body>

When i trying to send the mail, it is showing following error

ActionView::MissingTemplate (Missing template user_mailer/conference_result with "mailer". Searched in:* "user_mailer")

Please help me out,i am new to ruby .

3
Is there a conference_result email template in the user_mailer forlder?Philidor

3 Answers

3
votes

As the error says, Missing template user_mailer/conference_result.

You need to create a template app/views/user_mailer/conference_result.html.erb

0
votes

It seems you're missing the mail template itself. If you haven't got it, that explains the error - Otherwise I'd make sure it's in the right folder, probably app/views/user_mailer/conference_result.html.erb and .text.erb.

0
votes
https://myaccount.google.com/u/0/lesssecureapps

login your email then open above link. enable lesssecure app.