Coder Social home page Coder Social logo

Comments (16)

coderdave avatar coderdave commented on June 19, 2024 1

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.

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

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

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

I'm just setting up a basic hash. I would like to send from [email protected] 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 [email protected] if it's coming from a yahoo.com account :(
  from = self.from.include?("@yahoo.com") ? "[email protected]" : 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

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

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

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024
  sendgrid = SendGrid::Client.new do |c|
    c.api_key = ENV["SENDGRID_APIKEY"]
  end
  email = arg
  sendgrid.send email

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

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

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

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

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

Thanks! Please let us know how it goes.

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

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: '[email protected]')

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?

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

@coderdave,

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

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

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

{
  "from": {
    "email": "[email protected]",
    "name": "bing bong berry"
  },
  "subject": "hopefully can reply to",
  "personalizations": [
    {
      "to": [
        {
          "email": "[email protected]"
        }
      ]
    }
  ],
  "content": [
    {
      "type": "text/plain",
      "value": "Hello, Email!"
    }
  ],
  "reply_to": {
    "email": "[email protected]",
    "name": "bing bong berry"
  }
}

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

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

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

Same effect, email went through but it replies to "[email protected]"

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

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?

from sendgrid-ruby.

coderdave avatar coderdave commented on June 19, 2024

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 [email protected] one.

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on June 19, 2024

Thanks for following up with your solution!

from sendgrid-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.