Home All Groups Group Topic Archive Search About

Sending an email using System.Net.Mail or System.Web.Mail

Author
31 Mar 2006 11:12 PM
sanjeev
I am attempting to send an email from a C# app and get the following
error -

[System.Web.HttpException] = {"The server rejected one or more
recipient addresses. The server response was: 554 Relay rejected for
policy reasons.\r\n"}

I can only send emails to addresses within my domain. What do I have to
do in order to ensure that the mail server allows the emails to outside
addresses. I have attempted using classes from System.Net.Mail and
System.Web.Mail and get the same error if sending mail outside my
domain.

Here is a code snippet (I have edited the username/pwd) -

--------------------------------------------------------------------------------------------------------------------
            System.Web.Mail.MailMessage mail = new
System.Web.Mail.MailMessage();

            mail.From = "sen***@somecompany.com";
            mail.To = "cellph***@sprintpcs.com";

           mail.Subject = "This is an email";
            mail.Body = "The tulips are blooming!";



            try
            {
                //to authenticate we set the username and password
properites on the SmtpClient
                //  SmtpClient smtp = new SmtpClient("192.168.1.7");
                //smtp.Credentials = new NetworkCredential("username",
"pwd");
                //smtp.Send(mail);


                System.Web.Mail.SmtpMail.SmtpServer = "192.168.1.7";
                System.Web.Mail.SmtpMail.Send(mail);
            }
            catch (Exception ex)
            {
               Console.WriteLine(ex.Message);
            }

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

Regards,

Sanjeev.

Author
1 Apr 2006 2:10 PM
Christopher Reed
You have to talk to your mail administrator to allow for relaying of emails
from your web server.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<sanj***@securlinx.com> wrote in message
Show quote
news:1143846736.427731.3260@v46g2000cwv.googlegroups.com...
>I am attempting to send an email from a C# app and get the following
> error -
>
> [System.Web.HttpException] = {"The server rejected one or more
> recipient addresses. The server response was: 554 Relay rejected for
> policy reasons.\r\n"}
>
> I can only send emails to addresses within my domain. What do I have to
> do in order to ensure that the mail server allows the emails to outside
> addresses. I have attempted using classes from System.Net.Mail and
> System.Web.Mail and get the same error if sending mail outside my
> domain.
>
> Here is a code snippet (I have edited the username/pwd) -
>
> --------------------------------------------------------------------------------------------------------------------
>            System.Web.Mail.MailMessage mail = new
> System.Web.Mail.MailMessage();
>
>            mail.From = "sen***@somecompany.com";
>            mail.To = "cellph***@sprintpcs.com";
>
>           mail.Subject = "This is an email";
>            mail.Body = "The tulips are blooming!";
>
>
>
>            try
>            {
>                //to authenticate we set the username and password
> properites on the SmtpClient
>                //  SmtpClient smtp = new SmtpClient("192.168.1.7");
>                //smtp.Credentials = new NetworkCredential("username",
> "pwd");
>                //smtp.Send(mail);
>
>
>                System.Web.Mail.SmtpMail.SmtpServer = "192.168.1.7";
>                System.Web.Mail.SmtpMail.Send(mail);
>            }
>            catch (Exception ex)
>            {
>               Console.WriteLine(ex.Message);
>            }
>
> --------------------------------------------------------------------------------------------------------------------
>
> Regards,
>
> Sanjeev.
>
Author
1 Apr 2006 3:40 PM
Braulio Diez
Hello,

   Maybe you need to authenticate in order to send the e-mail (to avoid
spammers if you access to a remote e-mail server you need to authenticate
yourself).

   Some heplful links, if you use VStudio 2003 (.net framework 1.1)

   http://www.systemwebmail.com/allfaq.aspx

   If you are using VStudio 2005 (.net framework 2.0)

   http://www.systemnetmail.com/

   Good luck
           Braulio



--
/// ------------------------------
/// Braulio Díez   Colaborador DNM
///
/// http://www.dotnetmania.com
/// My Site (.net Tips): http://www.bdiez.com
/// ------------------------------




Show quote
"sanj***@securlinx.com" wrote:

> I am attempting to send an email from a C# app and get the following
> error -
>
> [System.Web.HttpException] = {"The server rejected one or more
> recipient addresses. The server response was: 554 Relay rejected for
> policy reasons.\r\n"}
>
> I can only send emails to addresses within my domain. What do I have to
> do in order to ensure that the mail server allows the emails to outside
> addresses. I have attempted using classes from System.Net.Mail and
> System.Web.Mail and get the same error if sending mail outside my
> domain.
>
> Here is a code snippet (I have edited the username/pwd) -
>
> --------------------------------------------------------------------------------------------------------------------
>             System.Web.Mail.MailMessage mail = new
> System.Web.Mail.MailMessage();
>
>             mail.From = "sen***@somecompany.com";
>             mail.To = "cellph***@sprintpcs.com";
>
>            mail.Subject = "This is an email";
>             mail.Body = "The tulips are blooming!";
>
>
>
>             try
>             {
>                 //to authenticate we set the username and password
> properites on the SmtpClient
>                 //  SmtpClient smtp = new SmtpClient("192.168.1.7");
>                 //smtp.Credentials = new NetworkCredential("username",
> "pwd");
>                 //smtp.Send(mail);
>
>
>                 System.Web.Mail.SmtpMail.SmtpServer = "192.168.1.7";
>                 System.Web.Mail.SmtpMail.Send(mail);
>             }
>             catch (Exception ex)
>             {
>                Console.WriteLine(ex.Message);
>             }
>
> --------------------------------------------------------------------------------------------------------------------
>
> Regards,
>
> Sanjeev.
>
>
Author
3 Apr 2006 2:12 PM
sanjeev
Thanks, I will follow up with for your suggestions.

Sanjeev


Braulio Diez wrote:
Show quote
> Hello,
>
>    Maybe you need to authenticate in order to send the e-mail (to avoid
> spammers if you access to a remote e-mail server you need to authenticate
> yourself).
>
>    Some heplful links, if you use VStudio 2003 (.net framework 1.1)
>
>    http://www.systemwebmail.com/allfaq.aspx
>
>    If you are using VStudio 2005 (.net framework 2.0)
>
>    http://www.systemnetmail.com/
>
>    Good luck
>            Braulio
>
>
>
> --
> /// ------------------------------
> /// Braulio Díez   Colaborador DNM
> ///
> /// http://www.dotnetmania.com
> /// My Site (.net Tips): http://www.bdiez.com
> /// ------------------------------
>
>
>
>
> "sanj***@securlinx.com" wrote:
>
> > I am attempting to send an email from a C# app and get the following
> > error -
> >
> > [System.Web.HttpException] = {"The server rejected one or more
> > recipient addresses. The server response was: 554 Relay rejected for
> > policy reasons.\r\n"}
> >
> > I can only send emails to addresses within my domain. What do I have to
> > do in order to ensure that the mail server allows the emails to outside
> > addresses. I have attempted using classes from System.Net.Mail and
> > System.Web.Mail and get the same error if sending mail outside my
> > domain.
> >
> > Here is a code snippet (I have edited the username/pwd) -
> >
> > --------------------------------------------------------------------------------------------------------------------
> >             System.Web.Mail.MailMessage mail = new
> > System.Web.Mail.MailMessage();
> >
> >             mail.From = "sen***@somecompany.com";
> >             mail.To = "cellph***@sprintpcs.com";
> >
> >            mail.Subject = "This is an email";
> >             mail.Body = "The tulips are blooming!";
> >
> >
> >
> >             try
> >             {
> >                 //to authenticate we set the username and password
> > properites on the SmtpClient
> >                 //  SmtpClient smtp = new SmtpClient("192.168.1.7");
> >                 //smtp.Credentials = new NetworkCredential("username",
> > "pwd");
> >                 //smtp.Send(mail);
> >
> >
> >                 System.Web.Mail.SmtpMail.SmtpServer = "192.168.1.7";
> >                 System.Web.Mail.SmtpMail.Send(mail);
> >             }
> >             catch (Exception ex)
> >             {
> >                Console.WriteLine(ex.Message);
> >             }
> >
> > --------------------------------------------------------------------------------------------------------------------
> >
> > Regards,
> >
> > Sanjeev.
> >
> >
Author
3 Apr 2006 3:07 PM
sloan
I have 1.1 and 2.0 example code.... at my blog..or using
No
Basic
SSL
authenication models for sending emails.

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




<sanj***@securlinx.com> wrote in message
Show quote
news:1143846736.427731.3260@v46g2000cwv.googlegroups.com...
> I am attempting to send an email from a C# app and get the following
> error -
>
> [System.Web.HttpException] = {"The server rejected one or more
> recipient addresses. The server response was: 554 Relay rejected for
> policy reasons.\r\n"}
>
> I can only send emails to addresses within my domain. What do I have to
> do in order to ensure that the mail server allows the emails to outside
> addresses. I have attempted using classes from System.Net.Mail and
> System.Web.Mail and get the same error if sending mail outside my
> domain.
>
> Here is a code snippet (I have edited the username/pwd) -
>
> --------------------------------------------------------------------------
------------------------------------------
>             System.Web.Mail.MailMessage mail = new
> System.Web.Mail.MailMessage();
>
>             mail.From = "sen***@somecompany.com";
>             mail.To = "cellph***@sprintpcs.com";
>
>            mail.Subject = "This is an email";
>             mail.Body = "The tulips are blooming!";
>
>
>
>             try
>             {
>                 //to authenticate we set the username and password
> properites on the SmtpClient
>                 //  SmtpClient smtp = new SmtpClient("192.168.1.7");
>                 //smtp.Credentials = new NetworkCredential("username",
> "pwd");
>                 //smtp.Send(mail);
>
>
>                 System.Web.Mail.SmtpMail.SmtpServer = "192.168.1.7";
>                 System.Web.Mail.SmtpMail.Send(mail);
>             }
>             catch (Exception ex)
>             {
>                Console.WriteLine(ex.Message);
>             }
>
> --------------------------------------------------------------------------
------------------------------------------
>
> Regards,
>
> Sanjeev.
>
Author
4 Apr 2006 3:00 PM
sanjeev
Thanks for the suggestions - the FAQ at System.Net.Mail is certainly
useful. Also, after speaking with the Sys Admin we discovered that the
Domino mail server is currently set to stop outgoing mail from any
client other than Lotus Notes. To test the proof of concept I am simply
using a gmail server.

Sanjeev

AddThis Social Bookmark Button