Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reply_to has no effect #52

Closed
coderdave opened this issue Mar 19, 2016 · 16 comments
Closed

reply_to has no effect #52

coderdave opened this issue Mar 19, 2016 · 16 comments
Labels
type: question question directed at the library

Comments

@coderdave
Copy link

I'm setting the reply_to but when you click to reply to the email, it's replying to the to email. Am I doing something wrong?

@thinkingserious
Copy link
Contributor

Hello @coderdave,

Could you please provide us with a code snippet so we can try to reproduce?

Also, this library will be replaced by the new version in a few weeks, you can check it out here: https://github.com/sendgrid/sendgrid-ruby/tree/v3beta

With Best Regards,

Elmer

@thinkingserious thinkingserious added the type: question question directed at the library label May 22, 2016
@coderdave
Copy link
Author

I'm just setting up a basic hash. I would like to send from info@mycutsapp.com but let them "reply_to" a different address, but it doesn't work. (Also the from_name isn't work either)

def send_it
  # send from info@mycutsapp.com if it's coming from a yahoo.com account :(
  from = self.from.include?("@yahoo.com") ? "info@mycutsapp.com" : self.from
  email = {
    from: from,
    from_name: self.from_name, # sendgrid isn't using the name set here, it uses the from email address
    reply_to: self.from, # no affect
    to: self.to.split(",").uniq,
    bcc: self.bcc.present? ? self.bcc.split(",").uniq : nil,
    subject: self.subject,
    text: strip_tags(self.message),
    html: self.message
  }

  MailerJob.new.async.perform("SendgridMailer", nil, email)
end

@thinkingserious
Copy link
Contributor

Hello @coderdave,

Thanks for the additional information.

Where are you setting up the SendGrid::Mail object? In the MailerJob? If so, can I take a look at that code?

Thanks!

Elmer

@coderdave
Copy link
Author

  sendgrid = SendGrid::Client.new do |c|
    c.api_key = ENV["SENDGRID_APIKEY"]
  end
  email = arg
  sendgrid.send email

@thinkingserious
Copy link
Contributor

thinkingserious commented May 27, 2016

email needs to be a SendGrid::Mail object. Please see: https://github.com/sendgrid/sendgrid-ruby#usage

@coderdave
Copy link
Author

Ah, ok, I'll try that. Thanks.

@thinkingserious
Copy link
Contributor

Thanks! Please let us know how it goes.

@coderdave
Copy link
Author

I finally got around to upgrading to v3. When I tested using reply_to, it still doesn't work.

mail.reply_to = SendGrid::Email.new(email: 'davidsanderson101@yahoo.com')

I get the email (to my gmail account) which is fine (and the custom name works) but when I try to reply to the email, it doesn't respect the reply_to I set up. It uses the regular reply email address that I used.

Is there something else I need to set?

@thinkingserious
Copy link
Contributor

@coderdave,

Before you make the call to API, could you please provide the output of:
puts JSON.pretty_generate(mail.to_json)

@coderdave
Copy link
Author

[43] pry(main)> puts JSON.pretty_generate(mail.to_json)

{
  "from": {
    "email": "info@mycutsapp.com",
    "name": "bing bong berry"
  },
  "subject": "hopefully can reply to",
  "personalizations": [
    {
      "to": [
        {
          "email": "coderdave@gmail.com"
        }
      ]
    }
  ],
  "content": [
    {
      "type": "text/plain",
      "value": "Hello, Email!"
    }
  ],
  "reply_to": {
    "email": "davidsanderson101@yahoo.com",
    "name": "bing bong berry"
  }
}

@thinkingserious
Copy link
Contributor

Please try putting that payload in a file named post.json

and run the following (after substituting your API key):

curl -X "POST" "https://api.sendgrid.com/v3/mail/send" \
        -H "Authorization: Bearer $SENDGRID_API_KEY"  \
        -H "Content-Type: application/json" \
        -d @post.json

@coderdave
Copy link
Author

Same effect, email went through but it replies to "info@mycutsapp.com"

@thinkingserious
Copy link
Contributor

Hmm, I can not reproduce the error with Gmail as the client. Do you mind sharing the raw headers of the email you receive in Gmail?

@coderdave
Copy link
Author

coderdave commented Jul 29, 2016

Ok, I see what's going on. It looks like the reply-to is being set but unfortunately, gmail doesn't respect it. That's too bad. Are there any workarounds for that?

hopefully_can_reply_to_-coderdave_gmail_com-_gmail

And it's strange that when I reply, it replies to my gmail account, not the info@mycutsapp.com one.

@coderdave
Copy link
Author

Update: I figured it out. I had my yahoo address set up in my gmail settings under "Send mail as"! So gmail was seeing that and used my gmail account instead.

Thanks for the help.

@thinkingserious
Copy link
Contributor

Thanks for following up with your solution!

jamietanna pushed a commit to jamietanna/sendgrid-ruby that referenced this issue Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

2 participants