So far so good...BUT, I can't find a way of inserting spaces in the body of the message to separate the paragraphs and also the signature at the bottom of the text.
I am using this code for the message body:
<input type=HIDDEN name="Message" value="This is the message which is about 20 lines long">
Is there some way I can break up the sentences so it doesn't come out as just one long continuous paragraph. I can't imagine that the creators of formmail would not have thought of this but I cannot find any reference to it anywhere.
Any ideas, colleagues?
You'd need some way to url-encode the line breaks, but I think if you used %, then the browser would url-encode that, not the result you want.
Including line breaks between the quotes in your hidden 'value' probably won't work either, the browser probably will just convert them to space characters, as it should.
If you do formmail and add line breaks in the body of the message (that you can type in, as opposed to a hidden field), the browser sees that you've pressed 'enter' or 'return' and sends those url-encoded. Formmail unencodes these and sends the message correctly.
There might be a way to get a browser to do it, but I can't think of any.
[added]
Well, you can. If you'll use some character sequence that is not really going to be in any other message, then modify formmail to do a replace on that sequence of characters, this will work.
$Form{'message') =~ s/yourspecialsequence/\n/;
@parse_body = split(/ /, $FORM{'message'});
foreach $_ (@parse_body) {
$x++;
$body .= "".$_." ";
if ($x == 15) {
$body .= "\n";
$x = 0;
}
elsif ($_ =~ /\n/) {
$x = 0;
}
}print MAIL $body; # Variable to write to E-mail
Are you just looking at the confirmation line (the output that formmail gives you that shows what you sent? That will NOT display as a new line because it is html. (it would if you used <pre> which is probably what formmail should output).
That's the correct syntax. You don't really want the space after the but the line should be broken in two.
Give me a link to the new one (or your version) and I'll be glad to take a look at it to see what's happening to these fields. (Could be a filter added to all input lines to strip newlines)
I got the script here:
[scriptarchive.com...]
I used:
<input type="hidden" name="message" value="This is a test Another line">
and the corresponding portion of the email returned:
message: This is a test
Another line
--
You can see that message broke into two lines. Using IE6 on win2k, outlook express.
<textarea name="testtextarea" rows="8" cols="40" >First line Second line</textarea>
This will make sure that your browser is reading the newline codes correctly. Are the lines separated by a blank line when you load the form?
Also, I don't think it should make a difference, but are you using GET or POST?
There are 2 problems.
I changed to just and got the same problem. Then before the mail had been sent I checked the raw data in the mailbox. Both IE AND Opera convert just the back to (carriage return/line feed)
Outlook does not like the carriage return ( ) it only expects the line feed (newline)
So add this line to formmail.pl
$value =~ s/\r//g;
right after these three lines:
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/\0//d;
That strips ANY carriage returns from any values sent (which shouldn't be there anyway)
@recipients = &fill_recipients(@referers);
But I want to use any email address as I am sending messages to clients, not myself. Do you know of a way to define this?
Thanks again, Bobriggs - hopefully, this will be the end of my problems ;-)
Stavs