[Mono-list] dot issues with system.net.mail.smtpclient
Peter Hagen
peter at wingsofdeath.net
Mon Jan 30 15:52:40 UTC 2012
Hi there,
Today I finally found my problem that occurs with sending my mailings.
To be brief, I send emails with alternativeview's containing one with
html and one with plain text. The html has links to images, and while it
mostly goes well, it sometimes fails. After checking the sources of
those emails, I discovered that a line, starting with a dot, is not
escaped with a dot. As an example here a part of the html:
/tr><tr id=3D"row1"><td width=3D"50px" nowrap=3D"on" align=3D"center"
valig=
n=3D"middle"><a
href=3D"http://www.wingsofdeath.net/content/16,18329"><img =
src=3D"http://www.wingsofdeath.net/cache/56178e3b58687a9e048d72ec93219b8b/2=
20120126095140.45x45.image001.jpg" border=3D"0" />
this is how its being received by the client. The filename should be:
2.20120126095140.45x45.image001.jpg
the dot falls incidentally on the first character. I checked the output
of mono to the mailserver with wireshark, and there the dot is visible.
While looking for the answer, I found out that Postfix (the mailserver I
use) states that every line starting with a dot, should be escaped with
a dot. Then I looked into the Mono code (2.10.6 & 8) and found the
following code (mcs/build/System/System.Net.Mail/SmtpClient.cs):
private void SendData (string data)
{
if (String.IsNullOrEmpty (data)) {
writer.Write("\r\n");
writer.Flush();
return;
}
StringReader sr = new StringReader (data);
string line;
bool escapeDots = deliveryMethod == SmtpDeliveryMethod.Network;
while ((line = sr.ReadLine ()) != null) {
CheckCancellation ();
if (escapeDots) {
int i;
for (i = 0; i < line.Length; i++) {
if (line[i] != '.')
break;
}
if (i > 0 && i == line.Length) {
line += ".";
}
}
writer.Write (line);
writer.Write ("\r\n");
}
writer.Flush ();
}
Escaping with this works if there is only a single dot, but when there
is a line starting with a dot, it wont escape it. So, is this a bug, or
is this to be compatible with .Net (4)? And if this is not a bug, is
there a (known Mono) way to get around this, without implementing
another mail library?
Cheers
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120130/c9be5bd2/attachment.html>
More information about the Mono-list
mailing list