By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

SMTP Sending Issue

P: n/a
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: XX*****@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
Jun 27 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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:
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: XX*****@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
Jun 27 '08 #2

P: n/a
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
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:
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: XXXX...@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
What encoding should I try? UTF8, Unicode, or UTF3....

Jun 27 '08 #3

P: n/a
Marty <ma***********@gmail.comwrote in news:54762a45-d5fc-4eaf-bb44-
5e**********@e53g2000hsa.googlegroups.com:
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
Jun 27 '08 #4

P: n/a
Start with Unicode. I think more things are supposed to be going to that.

"Marty" wrote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
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:
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: XXXX...@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

What encoding should I try? UTF8, Unicode, or UTF3....

Jun 27 '08 #5

P: n/a
On Jun 10, 2:44 pm, Marty <marty.wass...@gmail.comwrote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
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:
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: XXXX...@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

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;
Jun 27 '08 #6

P: n/a
Kenneth Porter <sh*************@sewingwitch.comwrote in
news:Xn**************************@207.46.248.16:
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/
Jun 27 '08 #7

P: n/a
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("fa*********@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:
On Jun 10, 2:44 pm, Marty <marty.wass...@gmail.comwrote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
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:
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: XXXX...@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
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;
Jun 27 '08 #8

P: n/a
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:
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: XX*****@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
Aug 11 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.