Skip to content

Handle Message With Empty Multipart Content - #54

Open
tres wants to merge 2 commits into
eddiezane:mainfrom
tres:master
Open

Handle Message With Empty Multipart Content#54
tres wants to merge 2 commits into
eddiezane:mainfrom
tres:master

Conversation

@tres

@tres tres commented Sep 16, 2019

Copy link
Copy Markdown

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
Copy Markdown
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