SMTP Sending Issue

M

Marty

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: (e-mail address removed)
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
 
J

jp2msft

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.
 
M

Marty

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.

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

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;
 
J

jp2msft

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("(e-mail address removed)");
// 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top