Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
11/3/2008 5:45:28 PM
Gravatar
Total Posts 4

Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

I have noticed there is a restriction of subject header of a email within 33 symbols when the email is sent from a forum by means of DotNetOpenMail. If more symbols are added a abracadabra turns out. Cry Could you please tell me, are there ways to increase this value?
11/4/2008 9:47:06 AM
Gravatar
Total Posts 18439

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

Hi Svetlana,

I got the email for your forum post and it is not truncated to 33 characters:

"[mojoPortal - Feature Requests] Subject header of a email when the email is sent from a forum by means of DotNetOpenMail"

So I don't think its a problem with DotNetOpenMail. There is a message template file used for the subject and another one for the body. In ForumPostEdit.aspx.cs you can see this code:

notificationInfo.SubjectTemplate
= ResourceHelper.GetMessageTemplate(ResourceHelper.GetDefaultCulture(),
"ForumNotificationEmailSubject.config");

Default culture is going to be from the Web.config setting:

<globalization
culture="auto:en-US"
uiCulture="auto:en-US"
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="iso-8859-15" />

default in this case is en-US so the template file will be /Data/MessageTemplates/en-US-ForumNotificationEmailSubject.config

if you have changed the default then maybe there is no template existing for the default culture and this could cause the problem you are seeing. The subject is formatted like this:

emailSubject.Append(notificationInfo.SubjectTemplate);
emailSubject.Replace("{SiteName}", notificationInfo.SiteName);
emailSubject.Replace("{ModuleName}", notificationInfo.ModuleName);
emailSubject.Replace("{ForumName}", notificationInfo.ForumName);
emailSubject.Replace("{Subject}", notificationInfo.Subject);

So most likely you are using a different culture and need to create a message template for your chosen culture.

Hope it helps,

Joe

11/4/2008 12:23:25 PM
Gravatar
Total Posts 4

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

Hi Joe!

Thank you for your reply :)

 I get this problem when I set non-ASCII encodings like utf-8 or koi8-r here:

 <add key="SmtpPreferredEncoding" value="utf-8" />

 

I have set a value directly: 

mail.Subject = "mojoPortallllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll"; 

and I have experimented options here: 

if (smtpSettings.PreferredEncoding.Length > 0)
  {
  mail.HeaderEncoding = DotNetOpenMail.Encoding.EncodingType.Base64;
  mail.HeaderCharSet = Encoding.GetEncoding(smtpSettings.PreferredEncoding);
  }
but these actions have not helped. :(

I think, that DotNetOpenMail defectively supports non-ASCII encodings. 

 

11/4/2008 12:35:23 PM
Gravatar
Total Posts 18439

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

I'm not sure about utf-8 but I have tested with non-ascii like this:

<add key="SmtpPreferredEncoding" value="koi8-r" />

for Russian chars and it worked.

Have you tried utf8 instead of utf-8?

Hope it helps,

Joe

11/4/2008 6:33:07 PM
Gravatar
Total Posts 4

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

 You are right, it is not a problem with DotNetOpenMail. I have set both values in the Email.cs directly: 

 mail.Subject = "mojoportalmojoportalmojoportalmojoportalmojoportalmojo";

 mail.TextPart = new TextAttachment("mojoportal");

and I have received the correct email.

 The problem arises when these values are taken from the en-US-ForumNotificationEmailSubject.config and en-US-ForumNotificationEmail.config files. Depending on a combination of Latin and Cyrillic characters in а subject header and a body of a email, a admissible quantity of characters in the subject header (which does not turn to abracadabra) varies. For example, if to write only Latin characters in both the subject header and the body, the admissible quantity of characters will be equal 53.

In case of the above-stated values in the above-stated files and such  setting: 

<add key="SmtpPreferredEncoding" value="koi8-r" /> 

I receive such email:

________________________________________

Subject: =?koi8-r?B?bW9qb3BvcnRhbG1vam9wb3J0YWxtb2pvcG9ydGFsbW9qb3BvcnRhbG1vam9wb3J0YWxtb2pvCg==

Body:

?=
Date: Wed, 5 Nov 2008 05:03:36 +0100
MIME-Version: 1.0
X-Mailer: DotNetOpenMail 0.5.8b
Content-Type: multipart/alternative;
  boundary="_=DotNetOpenMail=_l5eupyhrs04ztuokcnkifcm5ffzosyuqbu15"
X-Priority: 3
X-MSMail-Priority: Normal

This is a multi-part message in MIME format.

--_=DotNetOpenMail=_l5eupyhrs04ztuokcnkifcm5ffzosyuqbu15
Content-Type: text/plain;
  charset="koi8-r"
Content-Transfer-Encoding: base64

bW9qb3BvcnRhbAo=

--_=DotNetOpenMail=_l5eupyhrs04ztuokcnkifcm5ffzosyuqbu15--

 __________________________________________

 

My settings in the Web.config file:

<globalization
culture="en-US"
uiCulture="en-US"
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="iso-8859-15" />

<add key="SmtpPreferredEncoding" value="koi8-r" /> 

 

I use Linux (Debian etch4), mono from svn and mojoPortal from svn too. But Windows users which is not using mono complained of the same problem to me. 

 

 

11/5/2008 7:55:19 AM
Gravatar
Total Posts 18439

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

Hi Svetlana,

I think the languages installed on the client machines also affects what is seen in the subject line and body. I remember when testing this before on some machines the subject was not readable because the language codepage is not installed. So if I login to gmail on one machine it was readable but on another machine it was garbled because the language is not installed. For it to work the language must be installed on both the server and the client.

I also wonder if a problem may arise from the fact that the template file en-US-ForumNotificationEmailSubject.config is encoded as pc ansi/ascii

Best,

Joe


11/5/2008 1:44:34 PM
Gravatar
Total Posts 4

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

 All the same it is a problem with DotNetOpenMail.

When I have directly set the subject header of the email in length of 54 Latin characters in the Email.cs instead the 53, I have again received the garbled email.

Then I have written the following simple desktop application which does not have any relation to mojoportal: 

static void Main(string[] args)
  {
  System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("utf-8");
  EmailMessage emailmessage = new EmailMessage();
  EmailAddress japanesefromaddress = new EmailAddress("xxxxxxx@xx.ru", "Svetlana", EncodingType.Base64, encoding);
  EmailAddress japanesetoaddress = new EmailAddress("xxxxxxxxxx@xx.ru", "Budunduk", EncodingType.Base64, encoding);

  emailmessage.HeaderEncoding = DotNetOpenMail.Encoding.EncodingType.Base64;
  emailmessage.HeaderCharSet = System.Text.Encoding.GetEncoding("utf-8");

  emailmessage.FromAddress = japanesefromaddress;
  emailmessage.AddToAddress(japanesetoaddress);
  emailmessage.Subject = "mojoportalmojoportalmojoportalmojoportalmojoportalmojop";

  emailmessage.TextPart = new TextAttachment("mojoportal");
  emailmessage.TextPart.CharSet = System.Text.Encoding.GetEncoding("utf-8");
  emailmessage.TextPart.Encoding = DotNetOpenMail.Encoding.EncodingType.Base64;

  SmtpServer smtpServer = new SmtpServer("smtp.yandex.ru", 25);
  smtpServer.SmtpAuthToken = new SmtpAuthToken("xxxxxxxxxxx", "xxxxxx"); 
  emailmessage.Send(smtpServer);
  }

and I have once again received the garbled email. 

I have found discussion of a similar problem here:

http://sourceforge.net/forum/forum.php? thread_id=1812211&forum_id=441285 

but there this problem still have not solved.

 

11/5/2008 3:51:29 PM
Gravatar
Total Posts 18439

Re: Subject header of a email when the email is sent from a forum by means of DotNetOpenMail

Hi Svetlana,

It does sound like possible a problem with DotNetOpenMail.

The source code for the dll used in mojoPortal is available from here: https://forgesvn1.novell.com/svn/mojoportal/vendor/DotNetOpenMail

In case you want to try to solve it, you could remove the dll reference and use a project reference, then you can step through the code in VS

It sounds like a difficult problem to solve.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.