Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Closed Thread
 
Thread Tools Display Modes
Share |
  #1  
Old 01-28-2013, 12:02 AM
Vincentas Vincentas is offline
Banned
 
Join Date: 11-24-12
Posts: 202
iTrader: 0 / 0%
Get html Textarea and send it to mail

Hi,

I'm using the mail function and everything works fine. I want to get the result of a textarea and send it.
I need to send the break lines in my email as my textarea but I canīt do it.
My text is sent by email without the breaklines that I have in my textarea.

Any help, please?
 

Advertisement

Advertisement

  #2  
Old 03-28-2013, 11:25 AM
Plasmmirror Plasmmirror is offline
Junior Member
 
Join Date: 03-15-13
Location: Ukraine
Posts: 24
iTrader: 0 / 0%
Quote:
Originally Posted by Vincentas View Post
Hi,

I'm using the mail function and everything works fine. I want to get the result of a textarea and send it.
I need to send the break lines in my email as my textarea but I canīt do it.
My text is sent by email without the breaklines that I have in my textarea.

Any help, please?
Seems like there is a regexp in your script deleting linebreaks. More details would be good. Which script is sending mail?
 
  #3  
Old 03-28-2013, 11:40 AM
ScriptMan's Avatar
ScriptMan ScriptMan is offline
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,038
iTrader: 4 / 100%
Quote:
Originally Posted by Vincentas View Post
Hi,

I'm using the mail function and everything works fine. I want to get the result of a textarea and send it.
I need to send the break lines in my email as my textarea but I canīt do it.
My text is sent by email without the breaklines that I have in my textarea.

Any help, please?
You need to apply the nl2br($string) function to the text after it is received from the post form and before it is mailed or entered into the DB.

You can read more here: http://php.net/manual/en/function.nl2br.php
 
  #4  
Old 03-28-2013, 04:29 PM
LinkRogue LinkRogue is offline
Junior Member
 
Join Date: 03-28-13
Posts: 22
iTrader: 0 / 0%
You are incorrect in the majority of cases, ScriptMan.

The mail protocol uses newlines for creating breaks, not HTML elements (aka <br>). nl2br will convert those newlines to <br> tags, he is dealing with mail, not HTML.

It is likely something somewhere is stripping your newline characters, you would have to post your code for further investigation. Posting a textarea will indeed result in a string containing intact newlines, mailing that without modification works fine so it must be due to your code.
 
  #5  
Old 03-28-2013, 06:34 PM
ScriptMan's Avatar
ScriptMan ScriptMan is offline
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,038
iTrader: 4 / 100%
You are certainly welcome to correct me and if you can solve the OP's problem I feel pretty sure he will be pleased.
 
  #6  
Old 03-29-2013, 05:56 AM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 6,003
iTrader: 1 / 100%
Quote:
Originally Posted by LinkRogue View Post
You are incorrect in the majority of cases, ScriptMan.

The mail protocol uses newlines for creating breaks, not HTML elements (aka <br>). nl2br will convert those newlines to <br> tags, he is dealing with mail, not HTML.
That really depends on whether OP use plain text or html. If he uses html-email, then he needs to convert nl to <br>.

If he send the plain text from the textarea in a html-email, then he would have the issue he is describing. So, i think, either do as ScriptMan says or send the email as a plain text email could solve the issue.
 
  #7  
Old 03-29-2013, 05:58 AM
LinkRogue LinkRogue is offline
Junior Member
 
Join Date: 03-28-13
Posts: 22
iTrader: 0 / 0%
Exactly why I said "in the majority of cases" (:

Given the fact that he is using the mail function directly and hasn't mentioned HTML, I think it is safe to assume he is not using it (HTML emails really should be created using one of the popular email classes in PHP).

On a side note, if you're placing it into a literal string, make sure you are using double quotes, not single quotes. Although that'd only affect string literals not the POST var.
 
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check whether the mail has been successfully send using mail function in php? refilltuffy Coding Forum 5 06-07-2010 03:35 PM
Free WYSIWYG Textarea HTML Editor olddocks Coding Forum 6 12-31-2008 01:18 AM
HTML rich textarea ShareOurRevenue Coding Forum 2 01-11-2005 02:32 PM
Mail List - SQL - Send HTML Formatted Email? Sketch Coding Forum 2 12-15-2004 09:11 PM
<textarea> capacity? (html) Antinaris Coding Forum 1 04-24-2004 07:10 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:16 PM.
Powered by vBulletin
Copyright Đ 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC