i have build some website that take a message and send it to email recipient, the user can send emails by typing the message and the recipient. my issue is when a user type : "My \r\n name \r\n is \n user" the emails that have been sent is ignoring the linebreaks, or any html code inside the message, how can i support it ?
this is the html that have been sent:
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body >
<h3>Hi <%= @user.username %>,</h3>
<%= @message %>
</body>
</html>
CodePudding user response:
Using simple_format did the trick
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body >
<h3>Hi <%= @user.username %>,</h3>
<%= simple_format(@message) %>
</body>
</html>
https://www.rubydoc.info/docs/rails/3.1.1/ActionView/Helpers/TextHelper:simple_format