Connecting Tech Pros Worldwide Forums | Help | Site Map

SMTP Sending Issue

Marty
Guest
 
Posts: n/a
#1: Jun 27 '08
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:

Final-Recipient: XXXXXXX@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0

I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.

Here is my code:

MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();


Thanks
Marty

=?Utf-8?B?anAybXNmdA==?=
Guest
 
Posts: n/a
#2: Jun 27 '08

re: SMTP Sending Issue


Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.

"Marty" wrote:
Quote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
>
Final-Recipient: XXXXXXX@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
>
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
>
Here is my code:
>
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
>
>
Thanks
Marty
>
Marty
Guest
 
Posts: n/a
#3: Jun 27 '08

re: SMTP Sending Issue


On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
Quote:
Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.
>
"Marty" wrote:
Quote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
>
Quote:
Final-Recipient: XXXX...@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
>
Quote:
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
>
Quote:
Here is my code:
>
Quote:
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
>
Quote:
Thanks
Marty
What encoding should I try? UTF8, Unicode, or UTF3....

Kenneth Porter
Guest
 
Posts: n/a
#4: Jun 27 '08

re: SMTP Sending Issue


Marty <marty.wassmer@gmail.comwrote in news:54762a45-d5fc-4eaf-bb44-
5eab3b425ec1@e53g2000hsa.googlegroups.com:
Quote:
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
That suggests that there's a bug in SmtpClient.Send. The error message is
probably from the Postfix mail server and is saying that there's either a
LF or CR by itself on the end of a line. SMTP requires that lines end with
a CR followed by a LF.

Where does the SmtpClient class come from?

See section 2.3.7 (Lines) here:

http://www.faqs.org/rfcs/rfc2821
=?Utf-8?B?anAybXNmdA==?=
Guest
 
Posts: n/a
#5: Jun 27 '08

re: SMTP Sending Issue


Start with Unicode. I think more things are supposed to be going to that.

"Marty" wrote:
Quote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
Quote:
Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.

"Marty" wrote:
Quote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
Quote:
Final-Recipient: XXXX...@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
Quote:
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
Quote:
Here is my code:
Quote:
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
Quote:
Thanks
Marty
>
What encoding should I try? UTF8, Unicode, or UTF3....
>
>
Marty
Guest
 
Posts: n/a
#6: Jun 27 '08

re: SMTP Sending Issue


On Jun 10, 2:44 pm, Marty <marty.wass...@gmail.comwrote:
Quote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
>
>
>
Quote:
Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.
>
Quote:
"Marty" wrote:
Quote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
>
Quote:
Quote:
Final-Recipient: XXXX...@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
>
Quote:
Quote:
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
>
Quote:
Quote:
Here is my code:
>
Quote:
Quote:
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
>
Quote:
Quote:
Thanks
Marty
>
What encoding should I try? UTF8, Unicode, or UTF3....
I tried all encoding types with no luck. Here is the code I used
before the SmtpClient.Send().

mess.BodyEncoding = System.Text.Encoding.Unicode;
mess.SubjectEncoding = System.Text.Encoding.Unicode;
Kenneth Porter
Guest
 
Posts: n/a
#7: Jun 27 '08

re: SMTP Sending Issue


Kenneth Porter <shiva.blacklist@sewingwitch.comwrote in
news:Xns9AB98D9D6FF84shivawellcom@207.46.248.16:
Quote:
That suggests that there's a bug in SmtpClient.Send. The error message
is probably from the Postfix mail server and is saying that there's
either a LF or CR by itself on the end of a line. SMTP requires that
lines end with a CR followed by a LF.
Looks like this isn't the only bug:

http://www.themssforum.com/Framework...uthentication/

Get a copy of Wireshark and see what characters are really being exchanged.

http://www.wireshark.org/
=?Utf-8?B?anAybXNmdA==?=
Guest
 
Posts: n/a
#8: Jun 27 '08

re: SMTP Sending Issue


You aren't having conflicts between the MailMessage types, are you? I believe
the two types are System.Net.Mail and ...System.Web.Mail? (not sure about the
second)

Here is what my code looks like:
// ---------------------
bool ok = true;
MailAddress toMe = new MailAddress("fakeaddress@joeswelding.biz");
// txtEmail is a TextBox on the form:
MailAddress from = new MailAddress(txtEmail.Text); // from the form
System.Net.Mail.MailMessage Email =
new System.Net.Mail.MailMessage(from, toMe);
// Your host will probably be different. This is what I use on GoDaddy
SmtpClient server = new SmtpClient("relay-hosting.secureserver.net");
// txtMessage is a TextBox on the form:
string strHtmlBody = "<html><body>" + txtMessage.Text + "</body></html>";
Email.Subject = "Joe's Welding - Contact";
Email.Body = strHtmlBody;
Email.IsBodyHtml = true;
try {
server.Send(Email);
} catch (Exception err) {
Response.Write("<b>Unable to send: " + err.Message + "</b><br/>");
ok = false;
}
// ----------------------

Is this very different from what you are running?

"Marty" wrote:
Quote:
On Jun 10, 2:44 pm, Marty <marty.wass...@gmail.comwrote:
Quote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:


Quote:
Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.
Quote:
"Marty" wrote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
Quote:
Final-Recipient: XXXX...@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
Quote:
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
Quote:
Here is my code:
Quote:
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
Quote:
Thanks
Marty
What encoding should I try? UTF8, Unicode, or UTF3....
>
I tried all encoding types with no luck. Here is the code I used
before the SmtpClient.Send().
>
mess.BodyEncoding = System.Text.Encoding.Unicode;
mess.SubjectEncoding = System.Text.Encoding.Unicode;
>
=?Utf-8?B?UGFua2Fq?=
Guest
 
Posts: n/a
#9: Aug 11 '08

re: SMTP Sending Issue


Please look following articles for the sending email using SMTP.

http://www.a2zdotnet.com/View.aspx?id=38
http://www.a2zdotnet.com/View.aspx?id=50


--
regards,
Pankaj
http://www.A2ZDotNet.com


"Marty" wrote:
Quote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
>
Final-Recipient: XXXXXXX@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
>
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
>
Here is my code:
>
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
>
>
Thanks
Marty
>
Closed Thread