473,738 Members | 5,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*secon d 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 9075
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*secon d 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*secon d 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*secon d 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("f r", "");
$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.papr ika.net with Microsoft SMTPSVC(5.0.219 5.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 41E3CAB90000179 5 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*****@volley loisirs.server. org>
Message-ID: <91************ *************** ***@volleyloisi rs.server.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*****@volley loisirs.server. org> forward (org good)
Return-Path: ad*****@volleyl oisirs.server.o rg
X-OriginalArrival Time: 11 Jan 2005 15:46:49.0921 (UTC)
FILETIME=[C39E0310:01C4F7 F4]
------=_NextPartTM-000-c8e1a65e-e615-4f65-9337-a3f0937796e1
Content-Type: multipart/alternative;
boundary="b1_91 5ff4313334a04c1 6704ed017fe6331 "

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

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

première ligne*
*deuxième ligne

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

première ligne*
*deuxième ligne
--b1_915ff4313334 a04c16704ed017f e6331
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

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

Similar topics

4
2971
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 email by creating a text file, with content following certain format, and saving that file into the correct '..\mailroot\pickup' folder, and it is working fine
0
2204
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 Message</title></head> <body> <p>Hello {0}</p>
2
1508
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 mailMsg As New MailMessage mailMsg.From = rene.fehr@netradox.com mailMsg.To = info@netradox.com mailMsg.Subject = "Testmail vom Webforum" mailMsg.Body = "some body text"
6
2750
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
7
4386
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 framework reports the following exception: "System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown
2
1880
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 Object, e as EventArgs) 'Create an instance of the MailMessage class
5
1481
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 the form and included a couple free type multine textboxes. When the user presses submit an message is created with the responses and fired off to a MS Exchange mail enabled public folder.
0
2086
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 mail has to look like the following (Have put the body in double quotes) "The following numbers have been Un-validated for - PARIS 20 misrar 31/05/2007 14:13:52 55 misrar 31/05/2007 14:13:52 75 misrar ...
4
2847
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 does simply not read anything but the from and subject. The body is missing...
0
8968
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.