Skip to content

Possible email format problem in Chapter 20: Send Email - Create the Mailer View  #83

@morinoko

Description

@morinoko

In noticed a possible bug in Chapter 20: Send Email - Create the Mailer View

When implementing the app/views/user_mailer/contact_email.html.erb, we provide the DOCTYPE, head tags and body tags in the file.

screen shot 2016-03-30 at 18 01 25

However, when sending a test email, I first got a message within the email saying it could not be displayed because of the way it was formatted. Checking the console showed the email was given extra <html> and <body> tags on top of the ones that we already provided:

----==_mimepart_56fb928df1b01_cb43fd1e79cfc90908fe
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <body>
    <!DOCTYPE html>
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
  </head>
  <body>
    <h1>Website Contact</h1>
    <p>
      This visitor requested contact:
    </p>
    <p>
      Felice<br/>
      example@gmail.com<br/>
    </p>
    <p>
      The visitor said:
    </p>
    <p>
      "Test email"
    </p>
  </body>
</html>

  </body>
</html>

----==_mimepart_56fb928df1b01_cb43fd1e79cfc90908fe--

It seems that the Mailer is already providing the Doctype, head tags, as well as <html> and <body> tags. I removed the extra tags in the user_mailer/contact_email.html.erb file and it displayed fine after that:

screen shot 2016-03-30 at 18 08 30

Also no extra tags in the console outputs:

----==_mimepart_56fb93f0326df_cb43fd1e56ab638910fd
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <body>
    <h1>Website Contact</h1>
<p>
  This visitor requested contact:
</p>
<p>
  Felice<br/>
  example@gmail.com<br/>
</p>
<p>
  The visitor said:
</p>
<p>
  "test 2
"
</p>

  </body>
</html>

----==_mimepart_56fb93f0326df_cb43fd1e56ab638910fd--

Should this be changed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions