Hi all,

How can i send mails in rails 2.3.8 and schedule them when i need it.
i've tried with whenever gem but it did not work properly . can any one
help me out .

thanks in advance

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/zr8xSU8f1JAJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Terasawan at Jul 23, 2012 at 8:41 am
    Hi.

    I think you should use cron and `script/runner'.

    2012/7/20 honey ruby <emailtohoneyruby@gmail.com>:
    Hi all,

    How can i send mails in rails 2.3.8 and schedule them when i need it.
    i've tried with whenever gem but it did not work properly . can any one help
    me out .

    thanks in advance

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/zr8xSU8f1JAJ.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thota praneeth at Jul 23, 2012 at 11:37 am
    write the following code in development.rb

    config.action_mailer.raise_delivery_errors = false

    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
    :tls => true,
    :enable_starttls_auto => true,
    :address => 'smtp.gmail.com',
    :port => 587,
    :authentication => :plain,
    :user_name => 'youremail@gmail.com',
    :password => 'password'
    }


    in emailer model write the following code:

    class Emailer < ActionMailer::Base

    def contact(recipient, subject, message, sent_at = Time.now, files=[])
    @subject = subject
    @recipients = recipient
    @from = 'youremail@gmail.com'
    @sent_on = sent_at
    @body["title"] = 'This is title'
    @body["email"] = 'youremail@gmail.com'
    @body["message"] = message
    @headers = {}

    files.each do |file|
    attachment "application/octet-stream" do |a|
    a.body = file.read
    a.filename = file.original_filename
    end unless file.blank?
    end

    end
    end



    create one view and follow the code:



    <h1>Send Email</h1>
    <% form_for(:emailer, @emailer, :url=>{:action=>'sendmail'},
    :html=>{:multipart=>true}) do |f| %>
    <%= f.error_messages %>

    <p><label for="email_subject">Subject</label>:
    <%= text_field 'email', 'subject' %></p>
    <p><label for="email_recipient">Recipient</label>:
    <%= text_field 'email', 'recipient' %></p>
    <p><label for="email_message">Message</label><br/>
    <%= text_area 'email', 'message' %></p>
    <p><label for="file_upload">Upload</label><br/>
    <%= file_field 'email', 'file' %></p>
    <%= submit_tag "Send" %>
    <% end %>



    write the code in the controller:



    class EmailerController < ApplicationController
    def index

    end
    def sendmail

    @uploaded_files = []
    email = params["email"]
    puts email["file"]
    @uploaded_files << email["file"]
    recipient = email["recipient"]
    subject = email["subject"]
    message = email["message"]
    Emailer.deliver_contact(recipient, subject, message, @uploaded_files)
    return if request.xhr?
    @email = recipient
    @subject = subject
    @message = message
    render :file => 'app\views\emailer\contact.rhtml'
    end



    end

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJul 20, '12 at 11:22a
activeJul 23, '12 at 11:37a
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase