last day (14 days later) » 

10:46 AM
0
Q: delayed_job rake jobs:work rails 4 not sending mail

rohitUserMailer with delay method not working in rails 4. As mentioned below, this code doesn't works def welcome_email UserMailer.delay.welcome_email(self) end But when I use below code it works fine. UserMailer.welcome_email(self).deliver I have installed 2 gems, i.e gem 'delayed_job' gem '...

 
what error you are getting?
 
where do i need to run DelayedWorker?
@pulkit21 email is not being sent by the .delay
 
@rohit Try running this command rake jobs:work to start a job
 
@pulkit21 I had tried all that stuff required for delayed_job plugin, but email is been sent
 
@rohit run rails c and check the Delayed::Job.all. If jobs are there in the table or not
 
10:46 AM
hi pulkit
 
hi
run your rails console
 
there are no jobs in table
 
ok
 
look, Job UserMailer.welcome_email (id=3) COMPLETED after 8.9947
[Worker(host:Rohits-MacBook-Pro.local pid:2105)] 1 jobs processed at 0.1108 j/s, 0 failed
this shows when i run rake jobs:work
 
ya when you run rake jobs:work
it starts processing the job
which are there in the que
queue
 
10:49 AM
right now there is no job in the queue
 
yeah becoz when u ran that job
it process all the job
and nothing will be left
 
yes
 
Try sending the mail again with the proper email id
 
ok
 
then check you will get the email
 
10:54 AM
whats is the default time for .delay method?
 
it will start processing as soon as u start the job
untill u havent specified the time
 
i have'nt defined the specific time.. also its processing.. but the its not sending mail
 
for sending email are u using smtp setting or from localhost u sending
config.action_mailer.default_url_options = { :host => 'your.herokuapp.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
Authentication: "plain",
enable_starttls_auto: true,
user_name: your_username,
password: your_password
}
config.action_mailer.perform_deliveries = true
add this in your development.rb file
 
11:13 AM
I have alerady set these smtp setting, no email is being sent
 
then it might be u doing something wrong
in order to help u out have to see the code
what u doing
 
have you implemented the delayed_job plugin in your app?
these are the gems
gem 'delayed_job'
gem 'delayed_job_active_record'
this is the UserMailer
class UserMailer < ActionMailer::Base
default from: "from@example.com"

def welcome_email(article)
@article = article
mail(to: @article.email, subject: 'Background Email Test')
end
end
this is the model, through which
# user mailer
after_save :welcome_email

private
def welcome_email
UserMailer.delay.welcome_email(self)
end
 
yup
i have implemented one
 
is this alright?
which i mentioned
 
yup its correct
 
11:27 AM
ok
 
11:41 AM
can you provide me the code of yours, if possible
 

last day (14 days later) »