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

how can I send multipart mail? #289

Closed
hanahiroAze opened this issue Apr 12, 2018 · 2 comments
Closed

how can I send multipart mail? #289

hanahiroAze opened this issue Apr 12, 2018 · 2 comments
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: help wanted requesting help from the community type: question question directed at the library

Comments

@hanahiroAze
Copy link

hanahiroAze commented Apr 12, 2018

Issue Summary

I'm trying to send multipart(text/html) mail like below.

from = SendGrid::Email.new(email: "from_mail", name: "name")
to = SendGrid::Email.new(email: "to_mail")
subject = "subject"
contents = [::SendGrid::Content.new(type: "text/plain", value: "text"), ::SendGrid::Content.new(type: "text/html", value: "html")]

mail = SendGrid::Mail.new
mail.from = from
mail.subject = subject
personalization = SendGrid::Personalization.new
personalization.add_to(to)
mail.add_personalization(personalization)
mail.add_content(contents.first)
mail.add_content(contents.second)
mail.add_category(SendGrid::Category.new(name: BoronSettings.smtp.user))

sg = SendGrid::API.new(api_key: "api key")
sg.client.mail._("send").post(request_body: mail.to_json)

Steps to Reproduce

1. when I try like this 2mail have sent, is this expected behavior?
2. when I try like below "{\"errors\":[{\"message\":\"Invalid type. Expected: object, given: string.\",\"field\":\"content.0\",\"help\":null}]}", has been occurred. is this expected behavior?

mail.add_content(contents)

3. can I send multipart email?
https://sendgrid.kke.co.jp/docs/Tutorials/A_Transaction_Mail/send_transaction_mail.html

Technical details:

  • sendgrid-ruby Version: 5.2.0
  • Ruby Version: 2.4.2
@hanahiroAze
Copy link
Author

sorry I had misunderstood. the first behavior appeases my need.
now I wonder if I can set contents by array.

@thinkingserious
Copy link
Contributor

Hello,

Currently, add_content does not support passing in an array.

However, the next version of this SDK will support an add_contents method that will accept an array.

If you have a moment, your feedback on issue #177 would be most appreciated.

Thanks!

With Best Regards,

Elmer

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: question question directed at the library difficulty: unknown or n/a fix is unknown in difficulty labels Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: help wanted requesting help from the community type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

2 participants