sending mails

Z

Zeeway

hi,every one!
I have a question about sending emails.My codes works well over some smtp
servers,but doesn't over the others. My codes is listed belowed:
try
{
MailMessage mailObj = new MailMessage();
mailObj.To.Add(receipientAddr);
mailObj.From = new MailAddress(senderAddr);

mailObj.Subject = "very good";
mailObj.Body = "thank you";

mailObj.IsBodyHtml = true;
mailObj.Priority = MailPriority.High;
mailObj.BodyEncoding = System.Text.Encoding.UTF8;


System.Net.Mail.SmtpClient client = new
System.Net.Mail.SmtpClient(smtpServerIP);
client.UseDefaultCredentials = false;
mailObj.SubjectEncoding = System.Text.Encoding.UTF8;
client.Credentials = new
System.Net.NetworkCredential(this.tb_mailUserName.Text,
this.tb_mailUserPassword.Text);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mailObj);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}

when smtpServerIP is specified with some smtp server ips, the mail can be
delievered correctly.But over some smtp servers such as "smtp.21cn.com",the
codes didn't throw any exception and seemed to have work well,but when I
logined mail.21cn.com,I could not find the expectedly incoming mail. Could
anyone help me?

Crespo
2006-07-03
 
D

David P. Donahue

when smtpServerIP is specified with some smtp server ips, the mail can be
delievered correctly.But over some smtp servers such as "smtp.21cn.com",the
codes didn't throw any exception and seemed to have work well,but when I
logined mail.21cn.com,I could not find the expectedly incoming mail. Could
anyone help me?

Do you mean that mail is not being delivered if you use the DNS name,
but it is if you use the IP address? Or do you mean that some servers,
with no discernable pattern among them, simply aren't showing the emails
you're sending them?

If the former, check the DNS settings on the machine that's running the
code. I once encountered this problem on a web server where everything
was done by IP, and the DNS had never been configured.

If the latter, could it be that the mail server in question is filtering
the message as spam? HTML formatted, high priority, fewer than 10 bytes
of body text... could get flagged. Also, maybe that server is quietly
refusing to relay your message? Is the machine that's running the code
just some random host on the internet, from the perspective of that mail
server? It might only accept mail from "more reputable" hosts.

In terms of the MTA on that server, there could be plenty of reasons why
it's not accepting the message. If it thinks you're spam or trying to
improperly relay through it, it'll likely just ignore the message. If
there's a real error happening on their end, it should return a failure
message to whatever "senderAddr" is set to in your code (hopefully a
real email address).


Regards,
David P. Donahue
(e-mail address removed)
http://www.cyber0ne.com
 
N

Nicholas Paldino [.NET/C# MVP]

Zeeway,

This is the kind of thing where you have to have access to the server.
Also, what is the return address that you are placing in the email? Are you
getting anything at that return address indicating that the email was
invalid?

The SMTP mail classes are only going to throw an exception if there is a
transport problem, or if the server gives a response indicating that the
email is not accepted.

However, a server doesn't have to tell you that it rejected your message
when you send it. It will usually send a return message to the reply
address.

So I recommend you have the reply address set to an account you can
monitor, and then see what the server sends back to you. Either that, or
contact the mail admin at the server you are sending the mail to, and see if
that person can help you.

Hope this helps.
 
Z

Zeeway

Thanks for your attention. Following your advice,I specify a replyTo mail
address,but it still doesn't do the trick.
But thank you anyway.
Best Wishes

Crespo


Nicholas Paldino said:
Zeeway,

This is the kind of thing where you have to have access to the server.
Also, what is the return address that you are placing in the email? Are you
getting anything at that return address indicating that the email was
invalid?

The SMTP mail classes are only going to throw an exception if there is a
transport problem, or if the server gives a response indicating that the
email is not accepted.

However, a server doesn't have to tell you that it rejected your message
when you send it. It will usually send a return message to the reply
address.

So I recommend you have the reply address set to an account you can
monitor, and then see what the server sends back to you. Either that, or
contact the mail admin at the server you are sending the mail to, and see if
that person can help you.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Zeeway said:
hi,every one!
I have a question about sending emails.My codes works well over some smtp
servers,but doesn't over the others. My codes is listed belowed:
try
{
MailMessage mailObj = new MailMessage();
mailObj.To.Add(receipientAddr);
mailObj.From = new MailAddress(senderAddr);

mailObj.Subject = "very good";
mailObj.Body = "thank you";

mailObj.IsBodyHtml = true;
mailObj.Priority = MailPriority.High;
mailObj.BodyEncoding = System.Text.Encoding.UTF8;


System.Net.Mail.SmtpClient client = new
System.Net.Mail.SmtpClient(smtpServerIP);
client.UseDefaultCredentials = false;
mailObj.SubjectEncoding = System.Text.Encoding.UTF8;
client.Credentials = new
System.Net.NetworkCredential(this.tb_mailUserName.Text,
this.tb_mailUserPassword.Text);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mailObj);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}

when smtpServerIP is specified with some smtp server ips, the mail can
be
delievered correctly.But over some smtp servers such as
"smtp.21cn.com",the
codes didn't throw any exception and seemed to have work well,but when I
logined mail.21cn.com,I could not find the expectedly incoming mail.
Could
anyone help me?

Crespo
2006-07-03
 
S

sloan

Because different smtp servers uses different authentication models.

http://sholliday.spaces.live.com/
2/8/2006 entry

I have 1.1 and 2.0 downloadable code to show the differences.




Zeeway said:
Thanks for your attention. Following your advice,I specify a replyTo mail
address,but it still doesn't do the trick.
But thank you anyway.
Best Wishes

Crespo


"Nicholas Paldino [.NET/C# MVP]" <[email protected]> дÈëÏûÏ¢
Zeeway,

This is the kind of thing where you have to have access to the server.
Also, what is the return address that you are placing in the email? Are you
getting anything at that return address indicating that the email was
invalid?

The SMTP mail classes are only going to throw an exception if there
is
a
transport problem, or if the server gives a response indicating that the
email is not accepted.

However, a server doesn't have to tell you that it rejected your message
when you send it. It will usually send a return message to the reply
address.

So I recommend you have the reply address set to an account you can
monitor, and then see what the server sends back to you. Either that, or
contact the mail admin at the server you are sending the mail to, and
see
if
that person can help you.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Zeeway said:
hi,every one!
I have a question about sending emails.My codes works well over some smtp
servers,but doesn't over the others. My codes is listed belowed:
try
{
MailMessage mailObj = new MailMessage();
mailObj.To.Add(receipientAddr);
mailObj.From = new MailAddress(senderAddr);

mailObj.Subject = "very good";
mailObj.Body = "thank you";

mailObj.IsBodyHtml = true;
mailObj.Priority = MailPriority.High;
mailObj.BodyEncoding = System.Text.Encoding.UTF8;


System.Net.Mail.SmtpClient client = new
System.Net.Mail.SmtpClient(smtpServerIP);
client.UseDefaultCredentials = false;
mailObj.SubjectEncoding = System.Text.Encoding.UTF8;
client.Credentials = new
System.Net.NetworkCredential(this.tb_mailUserName.Text,
this.tb_mailUserPassword.Text);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mailObj);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}

when smtpServerIP is specified with some smtp server ips, the mail can
be
delievered correctly.But over some smtp servers such as
"smtp.21cn.com",the
codes didn't throw any exception and seemed to have work well,but when I
logined mail.21cn.com,I could not find the expectedly incoming mail.
Could
anyone help me?

Crespo
2006-07-03
 

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

Similar Threads

mail failed 6
sending mails 1
question about sending email 7
mail failed 3

Top