Email incoming in Action Mailer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Email incoming in Action Mailer

Aqib Hameed
I am working on Action mailer, email is sent successfully but incoming email not receiving.Below the code which i try
    user_mailer.rb
class UserMailer < ApplicationMailer
default from: "GMAIL_ACCOUNT"
def send_mail_agent(user)
@user = user

mail :to => user.email, :subject => "your ticket in process"

end

def receive(email)
page = Page.find_by(address: email.to.first)
page.emails.create(
subject: email.subject,
body: email.body
)

if email.has_attachments?
email.attachments.each do |attachment|
page.attachments.create({
file: attachment,
description: email.subject
})
end
end
end
end
 
development.rb 
    ActionMailer::Base.smtp_settings = {
    address:        'smtp.gmail.com', # default: localhost
port: '25', # default: 25
user_name: 'GAMIL_ACCOUNT',
password: 'GMAIL_PASSWORD',
authentication: :plain # :plain, :login or :cram_md5
}
I tried to run the command rails runner 'UserMailer.receive(STDIN.read)'

But nothing happened even the email is incoming .It does not call the receive method

Where should i call the receive method ??? How determine the incoming email ???


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/715f866f-2a6f-4551-ba1c-4be953c3ecf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email incoming in Action Mailer

Frederick Cheung-2
On Saturday, July 22, 2017 at 3:55:48 PM UTC+1, Aqib Hameed wrote:

>  }I tried to run the command rails runner 'UserMailer.receive(STDIN.read)'
>
> But nothing happened even the email is incoming .It does not call the receive method
> Where should i call the receive method ??? How determine the incoming email ???

Receiving email is rather more involved than sending it.
To use rails runner as you've tried this command needs to be run on your email server, by the email serving program itself (i.e. sendmail itself). There are variants on this but they all boil down to running your own mail server, which you may not want to do

Alternatively there are services like sendgrid, cloudmailin, Amazon ses. You set you ready dns records to that email to your domain (or a subdomain) is handled by this service provider and they'll make a regular http(s) call to your app whenever an email is received.

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ab691251-b045-414f-8d00-458f984cbe1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email incoming in Action Mailer

Aqib Hameed
Now I am using the gem mailman  and it work properly on receiving the email, 
mailman_server 
  require "rubygems"
require "bundler/setup"
require "mailman"

Mailman.config.logger = Logger.new("log/mailman.log")


Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: "[hidden email]",
password: "lahore786"

}

Mailman::Application.run do
default do
begin
Ticket.receive_mail(message)
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end
And run the command script/mailman_server and its work properly.
So it good approach which i mention above ??? or i try to use service provide "sendgrid, cloudmailin, Amazon ses"???

On Sunday, July 23, 2017 at 4:41:11 PM UTC+5, Frederick Cheung wrote:
On Saturday, July 22, 2017 at 3:55:48 PM UTC+1, Aqib Hameed wrote:

>  }I tried to run the command rails runner 'UserMailer.receive(STDIN.read)'
>
> But nothing happened even the email is incoming .It does not call the receive method
> Where should i call the receive method ??? How determine the incoming email ???

Receiving email is rather more involved than sending it.
To use rails runner as you've tried this command needs to be run on your email server, by the email serving program itself (i.e. sendmail itself). There are variants on this but they all boil down to running your own mail server, which you may not want to do

Alternatively there are services like sendgrid, cloudmailin, Amazon ses. You set you ready dns records to that email to your domain (or a subdomain) is handled by this service provider and they'll make a regular http(s) call to your app whenever an email is received.

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ec159bb3-63ae-4432-8f1c-0fa2cbea0d5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email incoming in Action Mailer

Frederick Cheung-2
On Sunday, July 23, 2017 at 1:59:00 PM UTC+1, Aqib Hameed wrote:
>
> And run the command script/mailman_server and its work properly.
> So it good approach which i mention above ??? or i try to use service provide "sendgrid, cloudmailin, Amazon ses"???

If you want to use your gmail address then you have to use something like the gem you found - the services I mention require you to have control over the whole domain.

You should change your password though, since you've just posted it on the internet.

Fred

> On Sunday, July 23, 2017 at 4:41:11 PM UTC+5, Frederick Cheung wrote:On Saturday, July 22, 2017 at 3:55:48 PM UTC+1, Aqib Hameed wrote:
>
>
>
> >  }I tried to run the command rails runner 'UserMailer.receive(STDIN.read)'
>
> >
>
> > But nothing happened even the email is incoming .It does not call the receive method
>
> > Where should i call the receive method ??? How determine the incoming email ???
>
>
>
> Receiving email is rather more involved than sending it.
>
> To use rails runner as you've tried this command needs to be run on your email server, by the email serving program itself (i.e. sendmail itself). There are variants on this but they all boil down to running your own mail server, which you may not want to do
>
>
>
> Alternatively there are services like sendgrid, cloudmailin, Amazon ses. You set you ready dns records to that email to your domain (or a subdomain) is handled by this service provider and they'll make a regular http(s) call to your app whenever an email is received.
>
>
>
> Fred
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/858862c6-056f-4f96-ab93-a7e3772ee0f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...