Rails ActionMailer: Contact form - getting the right headers - ruby-on-rails

On our webpage we have a contact form to let people contact us without sharing our email addresses.
We require a name, an email address and a message and allow people to send a copy to themselves.
On our server we have Postfix setup to send outgoing email.
Right now we add information as:
from = their email
to = our email and theirs if they want a copy. (could be cc instead)
It works okay, but just some weeks ago Gmail started to put all our emails in junk, even with explicit rules and stuff.
We figured out our Message-ID have the wrong format and added
def set_message_id(sent_at: Time.zone.now)
headers["Message-ID"] = "<#{Digest::SHA2.hexdigest(sent_at.to_i.to_s)}#domain.com>"
end
Based on an article from Mailgun and StackOverflow.
However we also get an SFP-softfail because we send the email from the users email, and the domain of their email does not have the same origin as our domain.
How do you solve this? We really like the way that you can instantly respond to a contact email and get the right name and email address automatically.
Is it worth investing in a service such as Mailgun just for this contact form?

Related

Change the Sender in Outlook using Redemption, but not with an account in the profile

I'm attempting to create Outlook emails that should be sent "from" someone other than the person actually sending the email. The idea is to prefill the email, display it in Outlook, allowing the end user to modify before sending. As a part of that process, I would like to use a different email address, which is a true email address, but is not an account in the end user's profile.
If this were SMTP, I could use the Net.Mail classes, which will accept any smtp address as the sender. Like this:
string from = "mytest#myorg.com";
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(from, to);
My question then, is it possible to do this using Redemption? All the examples that I've been able to find talk about either accessing the "Sender" property, or the "SendUsingAccount" property. From what I can tell, these both require an Account in the user profile.
If you are sending using Exchange (as well as most SMTP servers), it will not let you spoof the sender. The user must actually have the right to send as that user.

Is it possible for users to contact each other without knowing their email addresses via Mandrill?

My website allow User A send email to User B through a form. Currently if User B want to reply, he need to login to my website and use the same form.
User A dont know the User B's email address and vice versa.
I would like to allow User B reply to User A directly using his mail client without need to login to my website (while still keep both email addresses confidentially). So User A send a message to User B using the form. User B can reply to user A using his email client, and user B can reply to user A using email client too without reveal their email address.
I was told this is possible with Mandrill Webhook. Is that correct? Can anybody please show me how?
Thanks a lot.
I think what you need to do is inbound email processing.
First, create an inbound domain in your Mandrill dashboard.
Set up routes / webhooks in your dashboard (for example, sending an email to pm#example.com will send a POST to http://example.com/email-processing/pm).
In your application, process the received message and decide if you have to send it to one of your user, and more important, which user.
To do so, you can add a unique ID inside your emails. So you just have to read this ID when you receive an email, and you know who is the sender and who should be the receiver. Of course, you should also check the sender's email address.
More informations about the first two steps: http://help.mandrill.com/entries/21699367-Inbound-Email-Processing-Overview

Setting default from address of email in ios

In my app, there is an email functionality which should send email from an id, which is not configured with mail app. From address will be like noreplyATgmail.com .. some thing like that.
How can I hard code the from address of an email ?
It's impossible to send email from account where user isn't authorised in.
For your aims it's better implement email functionality on server side that could be authorised to send emails from address that you specified.
As per my comment - you can't, you should use reply-to for that, or send a request to a server to send the email. The from gets set from the selected email address you eventually chose to send the email with.
For example:
mailto:email#email.com?subject=Subject&reply-to=noreply#something.com
I don't think there's anyway to do this using MFMailComposeViewController.

How to mimic a mail being sent from a specified email from a contact us page ruby

I followed this tutorial to send emails from rails and it works just fine. But I want to improve this for my application. I don't really want to receive emails from myself all the time, if someone were to use the contact us page. Currently I have the mail settings set as my own email and sent to my own email. My question is, is there a way to set it up such that the mail I receive from the email sent through the contact us page is the email they put in in the form?
To clarify, for example in a standard contact us page, there is the name, email, subject, body. Right now when I route the mail to myself, the :from and :to parameter are my own email, is there a way to set the :from parameter of the mail to the email specified on the page? I have tried changing mail(:subject => "[YourWebsite.tld] #{message.subject}") to mail(:from => "#{message.from}", :subject => "[YourWebsite.tld] #{message.subject}") but that didn't seem to work, I'm not really sure what to google for this specific problem because most of the contact us page tutorials I have come up with are similar to the one I already tried, which is more specific for sending mail to others instead of receiving.
Thanks!
You should not attempt to change the from field; most mail servers will not let you for obvious reasons. What you should be able to do is add a reply-to header with the email given in the address box (though often this will be bogus, esp on spam). Be very careful of course to validate your input.
Incidentally I'd set up a separate email user for your server to send from, to avoid issues with using your own email account. So use:
:reply_to => message.from

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