473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

SMTP Sending Issue

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
8 3780
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JD | last post by:
Is it possible using the smtp class in asp.net to send emails and authenticate to the mail server that is sending the emails out. Currently I have a web application that works fine on my machine,...
2
by: 00_DotNetWarrior | last post by:
I followed this article to do authenticated SMTP, it works fine with port 25. (using .NET framework 1.1) http://support.microsoft.com/default.aspx?scid=kb;en-us;555287 However, if I change the...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
1
by: Benny Ng | last post by:
Dear All, Now I just finished my winform application. And a part of that is to send email reminder to the users. It's working fine in the server that with SMTP service in Windows 2003. But now...
1
by: | last post by:
Hi all, I am trying to send an email in some asp.net code and our SMTP Server (EXchange) keeps kicking back with this message:- Mailbox unavailable. The server response was: 5.7.1 Requested...
2
by: oliu321 | last post by:
Hi, First I am not trying to write a client to talk with hotmail straightly. I am trying to write some codes to send emails through a SMTP server. I wrote a C++ version using pure socket...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
5
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi, I'm using this code for sending emails and its working fine because I had configured SMTP in my machine in IIS. now I'm using machine as a server for this application. but when running the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.