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

Handle Message With Empty Multipart Content #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tres
Copy link

@tres tres commented Sep 16, 2019

Actionmailer is happy to have an empty text or html part to a multipart
message. This makes Sendgrid unhappy. Sendgrid will return an error when
attempting to send a message where a specific part of a multipart
message is empty.

This update allows for the behavior of actionmailer to coexist with the
requirements of the Sendgrid API.

            ##
           _[]_
          [____]
      .----'  '----.
  .===|    .==.    |===.
  \   |   /####\   |   /
  /   |   \####/   |   \
  '===|    `""`    |==='
  .===|    .==.    |===.
  \   |   /::::\   |   /
  /   |   \::::/   |   \
  '===|    `""`    |==='
  .===|    .==.    |===.
  \   |   /&&&&\   |   /
  /   |   \&&&&/   |   \
  '===|    `""`    |==='

jgs '--.______.--'

Actionmailer is happy to have an empty text or html part to a multipart
message. This makes Sendgrid unhappy. Sendgrid will return an error when
attempting to send a message where a specific part of a multipart
message is empty.

This update allows for the behavior of actionmailer to coexist with the
requirements of the Sendgrid API.

                ##
               _[]_
              [____]
          .----'  '----.
      .===|    .==.    |===.
      \   |   /####\   |   /
      /   |   \####/   |   \
      '===|    `""`    |==='
      .===|    .==.    |===.
      \   |   /::::\   |   /
      /   |   \::::/   |   \
      '===|    `""`    |==='
      .===|    .==.    |===.
      \   |   /&&&&\   |   /
      /   |   \&&&&/   |   \
      '===|    `""`    |==='
   jgs    '--.______.--'
This update removes angle brackets from an inline attachment's content
ID. As provided by actionmailer, there are angle brackets & Sengrid
wants to add their own angle brackets, which breaks the display of
inline attachments in the email.

             _____                                _______
           ,/_    ``-._                          /       \
          ,|:          `'-..__               ___|         |_
         ,|:_                 ``'''-----''''`_::~-.......-'~\
        ,|:_                                 _:    . ' .    :
        |:_                                  _:  .   '   .  |
        |:_                                  _:  '   .   '  |
        |:_                                  _:    ' . '    :
        |:_                    __,,...---...,,:_,.-'''''-.,_/
        |:_              _,.-``                 |         |
        |:_           ,-`                       |         |
        |:_         ,`                          |         |
        `|:_      ,'                            |         |
         |:_     /                              |         |
         `|:_   /                               |         |
          `|:_ :                                |         |
            \: |                                |         |
             \:|                                |         |
              ~
                       norse viking axe
                          cjr4may99
@tyrauber
Copy link
Collaborator

@tres, present? isn't available on Mail::Body, but the following should work:

unless !!(mail.text_part and mail.text_part.body)

We should also probably add a test to confirm this functions as expected.

Base automatically changed from master to main March 4, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants