Rails sending emails through an outside email service - ruby-on-rails

Alright so I've got an app in which users can send 'invitations' to other users to download files. What I'd like to do is set it up so that rather than using ActionMailer I can ask users for their username/pass to their Exchange email account and then send the invitations through their account. Ideally I'd like it so that after sending an invitation through their site it will also pop up under sent emails in their account. I'm a bit unsure about how to go about this besides a rough idea of a few ajax calls and wanted to see if anybody had any experience in something similar/good ideas about how to structure this.
Thanks ahead of time!

You would still need to use ActionMailer to send the email. However, you would be routing the email to be sent from ActionMailer through the user's SMTP server.
msg = MyMailer.some_message
msg.delivery_method.settings.merge!(#user.mail_settings)
msg.deliver
Where in the above mail_settings returns some hash with appropriate keys IE
{:user_name=>username, :password=>password}
There is more information regarding this on this post. How to send emails with multiple, dynamic smtp using Actionmailer/Ruby on Rails

Related

Email survey monkey survey automatically

Is it possible to automatically send a survey to everyone who registers at my website as soon as they are finished with the registration process? As I understand send_flow only sets up a flow and the user still has to send the email through the surverymonkey interface.
If you need to use the features of send_flow to distribute your invitation via SurveyMonkey's mailer, you can send the email immediately by setting "send" to true in your request to send_flow. The email will send in about 5 minutes as will all email sent from SurveyMonkey.
Using send_flow will create one collector for each request which could get unwieldy in SurveyMonkey's UI, but it will work.
Maybe you want to check out Examinare instead? You can with less than 10 code rows do this by combining the following functions:
Create the recipient:
https://developer.examinare.com/apidocs/addrecipient/
Send the email with the created ID:
https://developer.examinare.com/apidocs/sendsurvey/
I bet if you contact Examinare support email you will get help from them.

How do I associate notification mail reply to user's inbox?

I have an Rails web-application where a user can send message to any other registered user. Once a user sends a message to another user, another user gets a notification on application and also by email in his/her personal email inbox (Like basecamp).
I want to implement this functionality where if a user reply to a message from his/her personal email inbox(say gmail/yahoo), the message becomes available in the application and receiver gets a notification as usual.
As I could understand, we’ll need to associate a unique id and set it as reply-to field in notification mail. Any help in the right way to approach this problem will be very much appreciated.
Thank you
We are already using sendgrid. And sendgrid provides web-hook for emails. Which is quite easy to integrate with a rails application. It also uses mails gem. I'll keep posted if I find anything new on this.
I'm still working on finding out how to associate unique id in reply-to field in email. Any help on this will be much appreciated.
Thanks,
Chandan

Restrict access to url sent with Rails ActionMailer to recipient only

I've got a url I am sending users through ActionMailer. The person receiving the email is not a registered user. I want to restrict access to that certain url so only someone getting to it from the link in the mail can access it.
Is there a known way to do that?
One thought i had was to add a token parameter to the url and validate against it when trying to open the link.
Any better ideas? Thanks!

Example for sending a mail manually in rails

I have a web app and i want to add compose mail function so that the users can send the mail to others. I have searched for it and found only the confirmation mail sending after registration but i want the user to login and then he should be able to send a mail. how can i do this? Please help me.
You have to use action mailer to send mail,visit rails guilde.It's simple if you know little bit of rails

Verifying bounced email id in ruby on rails

I am building an email app in ruby on rails and I had a basic version which just used to send emails using AWS SES but recently I received a mail from AWS team saying that most of the email which I have sent had bounced back and they will discontinue my account if I send emails to the bounced email ids.
Is there any way to verify before sending email to any address that whether that email exists or not and valid or not.
Any gem or work around will help me a lot
The general way to do this is purely from a system design point of view. If you are going to collect an email address from one of your users and send them email periodically, or as events happen etc, then you should first ask them to "verify their email address". This typically involves generating a unique token, putting that into your database, linked with the user, then sending an email containing a URL with that unique token in it. The user clicks the link, which goes to a controller in your Rails application that matches the token against the user. If they can't follow that link, they can't read your emails, so don't send further email to that address.
If you obtained the email addresses through "other means", you're down to setting a Return-Path address on the outgoing email (bounces will be sent here), then checking that mailbox for bounces. I'm also often suspicious of how people happen upon a list of email addresses that didn't come from users consenting to an agreement with your website.
You could use the Mail gem to do this, but you need to know how to set up an SMTP server that pipes the email into your Rails application, which is not straightforward without prior experience. You can also use a variable Return-Path address (VERP), such as <some unique hash>+bounces#your-domain.com, where <some unique hash> references the email address in your system. This takes away the pain of trying to parse and interpret the bounce email, since the address it is sent to tells you who the bounced recipient is.

Resources