Mail not being sent to certain servers

Discussion for developers using MailEnable.
Post Reply
santanum
Posts: 3
Joined: Sat Aug 21, 2004 4:38 am
Location: India

Mail not being sent to certain servers

Post by santanum »

Hi,

We are experiencing a problem with the MailEnable Email server in a website we have developed and is hosted in a dedicated server. MailEnable has been installed there by the Hosting Company and we do not have access to its configuration etc.

Mails are being sent to <anyaddress>@digiavenues.com but whenever I try to send email to any other server like yahoo or msn the following exception is thrown.

System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response was: 501 This system is not configured to relay mail from to for 66.242.152.231 --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at ASP.TestMail_aspx.Page_Load(Object sender, EventArgs e)



I am using the following code snippet:

//C#
//--------------------------------------------------------------------------------

...
using System.Web.Mail;
...

MailMessage mail = new MailMessage();
mail.To = "smukherjee@digiavenues.com"; //Works
//mail.To = "smukherjee2002@msn.com"; //Does not Work
mail.From = "admin@benchmarkdental.com";
mail.Subject = "This is a test mail";
mail.Body = "some text goes here";
SmtpMail.SmtpServer = "mail.benchmarkdental.com";
SmtpMail.Send(mail);


//--------------------------------------------------------------------------------

Any help will be highly appreciated. Thanks.
Santanu M

sunpost
Posts: 438
Joined: Wed Sep 04, 2002 3:04 pm

Post by sunpost »

Most likely, they set up the SMTP to require authentication to relay.

To resolve this, supply the login credentials in your code...or have the host add the IP of the dedicated server to the privileged IP list.

santanum
Posts: 3
Joined: Sat Aug 21, 2004 4:38 am
Location: India

Another error

Post by santanum »

Hi,

As per your suggestion, I tried to supply the login credentials in my code.

The code is given below:

//C#
...

try
{
MailMessage mail = new MailMessage();
mail.BodyFormat = MailFormat.Text;
mail.From = "admin@benchmarkdental.com";

mail.Fields["http://schemas.microsoft.com/cdo/config ... smtpserver"] = "mail.benchmarkdental.com";
mail.Fields["http://schemas.microsoft.com/cdo/config ... serverport"] = 25;
mail.Fields["http://schemas.microsoft.com/cdo/config ... /sendusing"] = 2;
mail.Fields["http://schemas.microsoft.com/cdo/config ... thenticate"] = 1;
mail.Fields["http://schemas.microsoft.com/cdo/config ... ndusername"] = "<username>";
mail.Fields["http://schemas.microsoft.com/cdo/config ... ndpassword"] = "<password>";



mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.To = "smukherjee2002@msn.com";

SmtpMail.SmtpServer = "mail.benchmarkdental.com";
SmtpMail.Send( mail );
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
...

----------------------------------------------------------------------

When I run this code an exception is thrown:

System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at ASP.TestMail_aspx.Page_Load(Object sender, EventArgs e)

Help needed. :)
Santanu M

sunpost
Posts: 438
Joined: Wed Sep 04, 2002 3:04 pm

Post by sunpost »

you might want to check the SmtpServer.

mail.benchmarkdental.com says that it is ModusMail.
benchmarkdental.com says that it is ME.

try using SmtpMail.SmtpServer = "benchmarkdental.com";
for the SmtpServer in the first example and see if it works.

santanum
Posts: 3
Joined: Sat Aug 21, 2004 4:38 am
Location: India

Working!!!

Post by santanum »

Hi,

Ultimately it worked with the following code snippet:


try
{
MailMessage mail = new MailMessage();
mail.BodyFormat = MailFormat.Text;
mail.From = "admin@benchmarkdental.com";

mail.Fields["http://schemas.microsoft.com/cdo/config ... thenticate"] = 1;
mail.Fields["http://schemas.microsoft.com/cdo/config ... ndusername"] = "<username>";
mail.Fields["http://schemas.microsoft.com/cdo/config ... ndpassword"] = "<password>";

mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.To = "smukherjee1976@yahoo.com";

SmtpMail.SmtpServer = "benchmarkdental.com";
SmtpMail.Send( mail );
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}

----------------------------------------------------------------
There is a small problem though. I found that in msn the message was in the Junk Mail folder. Any clues?

Anyway, thanks very very much for your help. It is really a good forum.

Thanks again.

:D
Santanu M

sunpost
Posts: 438
Joined: Wed Sep 04, 2002 3:04 pm

Post by sunpost »

the SMTP logs will help you diagnose the failure.

Post Reply