473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

sending multiline mail in text format

hi,
Bonjour,

I'm using PHPMailer class to send mails and it works fine for HTML ones.

But I can't manage to send correctly a text formatted mail...
I tried this :
- $message = "first line*\n*second line";
- $message = "first line*\r\n*second line";
- $message = "first line*".chr(13).chr(10)*second line";
- $message = "first line*
*second line";

Result is always the same (I tried many mail readers like Outlook express,
Yahoo, ...) : the body appears on only one line, with a space between the 2
*, instead of a carriage return...
first line* *second line

Thanks for any idea !
Jul 17 '05 #1
14 8994
Christophe Cerbourg wrote:
hi,
Bonjour,

I'm using PHPMailer class to send mails and it works fine for HTML
ones.

But I can't manage to send correctly a text formatted mail...
I tried this :
- $message = "first line*\n*second line";
- $message = "first line*\r\n*second line";
- $message = "first line*".chr(13).chr(10)*second line";
- $message = "first line*
*second line";

Result is always the same (I tried many mail readers like Outlook
express, Yahoo, ...) : the body appears on only one line, with a space
between the 2 *, instead of a carriage return...
first line* *second line

Thanks for any idea !


I guess the mail is sent as HTML anyway, and an end of line is just
whitespace in HTML in most circumstances.

Check the source of the email message to see if this is the case (Ctrl + F3
?)

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
Jul 17 '05 #2
nc
Christophe Cerbourg wrote:

I'm using PHPMailer class to send mails and it works fine for HTML ones.
But I can't manage to send correctly a text formatted mail...
I tried this :
- $message = "first line*\n*second line";
- $message = "first line*\r\n*second line";
- $message = "first line*".chr(13).chr(10)*second line";
- $message = "first line*
*second line";

Result is always the same (I tried many mail readers like Outlook
express, Yahoo, ...) : the body appears on only one line, with
a space between the 2 *, instead of a carriage return...


You probably call IsHTML(true) somewhere... This makes PHPMailer
generate e-mail headers that suggest that the message body is
HTML while it is in fact plain text. The recepient client
attempts to render it as HTML, and so you have your line breaks
missing in this incorrect rendition...

Cheers,
NC

Jul 17 '05 #3
nc@iname.com wrote:
Christophe Cerbourg wrote:
I'm using PHPMailer class to send mails and it works fine for HTML


ones.
But I can't manage to send correctly a text formatted mail...
I tried this :
- $message = "first line*\n*second line";
- $message = "first line*\r\n*second line";
- $message = "first line*".chr(13).chr(10)*second line";
- $message = "first line*
*second line";

Result is always the same (I tried many mail readers like Outlook
express, Yahoo, ...) : the body appears on only one line, with
a space between the 2 *, instead of a carriage return...

You probably call IsHTML(true) somewhere... This makes PHPMailer
generate e-mail headers that suggest that the message body is
HTML while it is in fact plain text. The recepient client
attempts to render it as HTML, and so you have your line breaks
missing in this incorrect rendition...

Cheers,
NC

To try and confirm this, you could look at the original message, as it
is seen by the mail reader. i.e. unparsed. That should give you some
clue as to what type of document it is being sent as.

HTH
--
Ron Chaplin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
T73 Software & Design
www.t73-softdesign.com
To provide custom and quality
software, designs and services,
to our customers, at an affordable rate,
with minimal delay.
Jul 17 '05 #4
cc
You probably call IsHTML(true) somewhere...


here is the complete code used for testing :
$message = "première ligne*\n*deuxième ligne";

$monmail = new PHPMailer();
$monmail->SetLanguage("fr", "");
$monmail->IsHTML(False);

// $monmail->Encoding = "base64";
$monmail->From = "me@home.fr";
$monmail->FromName = "xxx";
$monmail->ClearAddresses();
$monmail->ClearCCs();
$monmail->ClearBCCs();
$monmail->AddAddress("ad*****@voila.fr");

$monmail->Subject = "test";
$monmail->Body = $message;
$monmail->AltBody = $message;

if ($monmail->Send()) { echo "ok 1"; } else { echo "erreur"; }

and here is the result :
première ligne* *deuxième ligne

But, as you suggest, I will have a look to the whole content of message...
Thanks anyway !
Jul 17 '05 #5
cc
To try and confirm this, you could look at the original message, as it
is seen by the mail reader. i.e. unparsed. That should give you some
clue as to what type of document it is being sent as.


hi Ron, thanks for your help.

Here is the complete message in which I don't understand anything...
Is it correct for a TEXT mail or not ?

Received: from serveur20.dns-oi.com ([213.11.110.6]) by
decalogexc.paprika.net with Microsoft SMTPSVC(5.0.2195.6713);
Tue, 11 Jan 2005 16:46:49 +0100
Received: from serveur41 (212.208.222.4) by serveur20.dns-oi.com (NPlex
5.1.036)
id 41E3CAB900001795 for ad*****@server.net; Tue, 11 Jan 2005
16:39:41 +0100
Received: from 212.208.222.4 by serveur41 (InterScan E-Mail VirusWall NT);
Tue, 11 Jan 2005 16:39:41 +0100
Received: from source ([212.208.222.4]) by host ([212.208.222.4]) with SMTP;
Tue, 11 Jan 2005 16:39:41 +0100
Received: from phpnet.org ([195.137.249.140])
by serveur41.dns-oid.com (OID Mail Server v3.0) with SMTP id
GLD38335
for <ad*****@server.net>; Tue, 11 Jan 2005 16:39:41 +0100
Received: (qmail 27424 invoked by uid 502); 11 Jan 2005 15:39:52 -0000
Received: from unknown (HELO cluster2.phpnet.org) (10.0.0.38)
by 10.0.0.101 with SMTP; 11 Jan 2005 15:39:52 -0000
Received: (qmail 23718 invoked by uid 510); 11 Jan 2005 15:39:35 -0000
To: ad*****@server.net
Subject: test
Date: Tue, 11 Jan 2005 16:39:35 +0100
From: volleyloisirs <ad*****@volleyloisirs.server.org>
Message-ID: <91******************************@volleyloisirs.se rver.org>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPartTM-000-c8e1a65e-e615-4f65-9337-a3f0937796e1"
X-pstn-version: pmps:sps_win32_1_1_0c1 pase:2.8
X-pstn-levels: (C:78.1961 M:98.9607 P:95.9108 R:95.9108 S: 1.1377 )
X-pstn-settings: 4 (0.2500:0.7500) p:14 m:14 C:14 r:14
X-pstn-addresses: from <ad*****@volleyloisirs.server.org> forward (org good)
Return-Path: ad*****@volleyloisirs.server.org
X-OriginalArrivalTime: 11 Jan 2005 15:46:49.0921 (UTC)
FILETIME=[C39E0310:01C4F7F4]
------=_NextPartTM-000-c8e1a65e-e615-4f65-9337-a3f0937796e1
Content-Type: multipart/alternative;
boundary="b1_915ff4313334a04c16704ed017fe6331"

--b1_915ff4313334a04c16704ed017fe6331
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

première ligne*
*deuxième ligne
--b1_915ff4313334a04c16704ed017fe6331
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

première ligne*
*deuxième ligne

--b1_915ff4313334a04c16704ed017fe6331--
------=_NextPartTM-000-c8e1a65e-e615-4f65-9337-a3f0937796e1--
Jul 17 '05 #6
*** cc wrote/escribió (Tue, 11 Jan 2005 16:45:44 +0100):
--b1_915ff4313334a04c16704ed017fe6331
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

première ligne*
*deuxième ligne
--b1_915ff4313334a04c16704ed017fe6331
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

première ligne*
*deuxième ligne


You are sending two copies of the body message: a text plain and an HTML
version. Your mail client probably displays the HTML version which, as you
can see, has not markup tags at all.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #7
*** cc wrote/escribió (Tue, 11 Jan 2005 14:20:42 +0100):
$monmail->Body = $message;
$monmail->AltBody = $message;


http://phpmailer.sourceforge.net/docs/

string $AltBody = "" (line 96)

Sets the text-only body of the message. This automatically sets the email
to multipart/alternative. This body can be read by mail clients that do not
have HTML email capability such as mutt. Clients that can read HTML will
view the normal Body.

Duplicating the body makes no sense it you aren't sending formatted text.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #8
cc
thanks Alvaro for your help.

I had understood, while reading this help, that I could avoid writing a HTML
message if I wanted it to be always displayed in text. But it seems I always
have to write it in HTML because if I only set the AltBody property, the
mail is empty with OE, for example...

So I have to set two versions of my poor text message, one with <br> in the
body, and one with \n in the AltBody ?

It works fine if I do that, but it makes me feel programming is really a
stupid job, sometimes...

Anyway, thanks !
Jul 17 '05 #9
*** cc wrote/escribió (Tue, 11 Jan 2005 17:43:04 +0100):
I had understood, while reading this help, that I could avoid writing a HTML
message if I wanted it to be always displayed in text. But it seems I always
have to write it in HTML because if I only set the AltBody property, the
mail is empty with OE, for example...


You don't have to set the AltBody property for plain text. Alternative to
what?? Just leave it apart.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #10
nc
cc wrote:
You probably call IsHTML(true) somewhere...
here is the complete code used for testing :


And here is the line that is responsible for your problems:
$monmail->AltBody = $message;


You don't need AltBody for a plain-text message. You should
delete this line.

Cheers,
NC

Jul 17 '05 #11
cc
You don't have to set the AltBody property for plain text. Alternative to
what?? Just leave it apart.


yes I have to...
if I send "first line*<br>*second line" with $MyMail->IsHTML(False), most of
mail readers display
first line*
*second line
but not all of them !
Some display :
first line*<br>*second line

If I send <br> in Body and \n in AltBody, mail is correctly displayed in ALL
mail readers I tested.

Thanks !
Jul 17 '05 #12
cc
> You don't need AltBody for a plain-text message. You should
delete this line.


thanks for your help
see my answer to Alvaro please...
Jul 17 '05 #13
*** cc wrote/escribió (Wed, 12 Jan 2005 09:23:39 +0100):
yes I have to...
if I send "first line*<br>*second line" with $MyMail->IsHTML(False), most of
mail readers display
first line*
*second line
but not all of them !
Some display :
first line*<br>*second line


Which is the correct behaviour. Your original post is titled "sending
multiline mail in text format". Why do you want to put HTML tags in a plain
text message and get them parsed?
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #14
cc
> Which is the correct behaviour. Your original post is titled "sending
multiline mail in text format". Why do you want to put HTML tags in a plain text message and get them parsed?


Well... What I wanted to to was just send a very simple text message, in
text format.

But I also want the very simple message to have 2 lines !

So I first send message like this :
$message = "première ligne*\n*deuxième ligne";

$monmail = new PHPMailer();
$monmail->SetLanguage("fr", "");
$monmail->IsHTML(False);
....
$monmail->Subject = "test";
$monmail->Body = $message;

if ($monmail->Send()) { echo "ok 1"; } else { echo "erreur"; }

As result was not what I guessed ("première ligne* *deuxième ligne" instead
of
première ligne*
*deuxième ligne)

I tried many more other things and finally ask in this newsgroup.

Now I have a solution, thanks for this, but am surprised not to have a
simple solution for such a simple need...
If I want my 2 lines messages be seen as this by every news reader, I have
to set both Body and AltBody properties, one with "<br>" and the other with
"\n", which is not very complicated, but not as simple as I hoped !
Jul 17 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
0
by: David Dvali | last post by:
Hello. I have a problem with sending Unicode text in mail message. So what I do: First of all I have some template file like this: ================================= <html> <head><title>Test...
2
by: Rene | last post by:
Hi all i need some help. i try to send mail with the following code. Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
7
by: Ray Booysen | last post by:
Hi all I'm sending email via ASP.NET in HTML mode. Each email has exactly one attachment and I do have full access to the SMTP server. However, if I send the email in HTML format, the...
2
by: RAB | last post by:
I have a .aspx page with the following code: <% @Import Namespace="System.Web.Mail" %> <%@ page language="vb" debug="true" runat="server" %> <script runat="server"> Sub Click(sender as...
5
by: =?Utf-8?B?VG9ueSBXaXNzbGVy?= | last post by:
Hello everyone- I am hoping a couple of you will have some ideas on this one... I have a webform created in visual basic 2005. Basically, the webform gather answers to the questions asked on...
0
by: misra | last post by:
Hi, I am using a C# code to call blat and send mail. When I send mails with long sentences, the mail automatically is send with multiple lines. However, certain times the body and format of the...
4
by: Sonnich Jensen | last post by:
Hi all! I use the following for sending mail from ASP, but there is a problem - it goes to a intranet thing (eRoom) which does not read it, while Outlook etc does not have any problems. eRoom...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.