Difficulty emailing from code

Discussion in 'ASP.NET / ASP.NET Core' started by Swood, Jul 11, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. try

    SmtpMail.SmtpServer = "localhost";
     
  2. I am trying to send a mail from a simple .net page. I continually getting an error like:
    "The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts "

    If I use a email address within my domain, it works, but for all other email addresses it does not.

    Any hints or suggestions greatly appreciated.
    Here is my test script :

    <%@ Page Language="C#" Debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %>

    <%@ Import Namespace="System.Web.Mail" %>

    <script runat="server">

    void Page_Load(Object sender , EventArgs e)

    {

    SmtpMail.SmtpServer = "mail.mydomain.com";

    MailMessage objMailMessage;

    string strHTMLBody;

    // Create the HTML Message Body

    strHTMLBody = "<html><head>" + "<title>Dynamic email</title>" + "</head>" +

    "<p>This is a test email<p></body></html>";

    // Create the Mail Message

    objMailMessage = new MailMessage();

    objMailMessage.From = "[email protected]";

    objMailMessage.To = "[email protected]";

    objMailMessage.Subject = "Testing..!?";

    objMailMessage.Body = strHTMLBody;

    objMailMessage.BodyFormat = MailFormat.Html;

    // Send the Mail Message

    SmtpMail.Send( objMailMessage );

    Response.Write("HTML Email Sent!");

    }

    </script>
     
  3. Worked like a charm,
    Thanks so much!

    Powell
     
  4. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

    Please send in a support ticket with details, eg error message...etc

    DiscountASP.NET
     
  5. I am recieving this error when emailing from ms outlook. If I have the person I am sending the email to add me onto their contacts list, the email goes through. At first I thought it was junk mail blocking. But as I was doing research, I found it related to an internal error. Any suggestions would be great.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page