Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

290
Visualizações
Add a Line Break In HTML Email

I have made a request form for my work and it working as expected. I have placed some text in the text area as a hide/show for users. On the visual studio code, I see the line breaks fine but when I submit the form and the recipient gets the email all that was in the text area is all in one line instead of line break where I wanted.

Also how to kill the extra white spaces. Also have used this

Is there any fix to this?

I get this in email DC GM Groups Domain Group Access:  All Folders and Drives Required Distribution List:  All Emails

Tried everything I could research but doesn't seem to work

white-space: nowrap;
text-align: left;
width: 650px;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-6">
  <!-- style="visibility:hidden;" -->
  <!-- acc means account -->
  <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10">
Domain Group Access:&#13;&#10;&emsp;All Folders and Drives Required&#13;&#10;
Distribution List:&#13;&#10;&emsp;All Emails

                            </textarea>
</div>

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

To answer your first two questions

The easiest way to format like it is in the text area is to put the text between <pre>...</pre> tags

The other thing you could do is use regular expressions to switch from text to html, like

text.replace(/[\n]/g,"<br>");
text.replace(/\s\s+/g,function(part) {
  return part.substring(0,1);
}));
about 4 years ago · Juan Pablo Isaza Relatório

0

A textarea will render whitespace as it was entered into the element so just format the whitespace by literally adding it.

<div class="col-6">
  <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10">
Domain Group Access:
 All Folders and Drives Required
 
Distribution List:
 All Emails
  </textarea>
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

So i was able to do deep research and found you can do this to make it work: just add nl2br

$usersGMGroup = nl2br($_POST["acc_GMGroup"]);

Thank you to all the people that helped to resolve the issue

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda