Email Security Problem from an Assembly

Discussion in 'ASP.NET / ASP.NET Core' started by Major_Disorder, Jul 21, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,
    I've written a class that sends an email using the SendEmail method (surprise, surprise). The method call works just fine if I call it directly from an ASPX page using the following:

    <%@ Page Language="VB" %>
    <%@ Import Namespace="mynamespace" %>
    <script runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim o As Utils = New Utils

    o.SendEmail("[email protected]","[email protected]","Subject","Body")

    lblMessage.text = "Mail Sent"
    End Sub
    </script>

    However, if I try to call the method from another class no email is delivered. I can't debug this as it's on the discount.asp servers.

    Any one got any ideas what I'll need to change?

    BTW the other class calling the SendEmail method is in the same assembly.


    ***SEND EMAIL***
    public bool SendEmail(string sTo, string sFrom, string sSubject, string sBody)
    {
    try
    {
    MailMessage oMsg = new MailMessage();

    oMsg.From = sFrom;
    oMsg.To = sTo;
    oMsg.Subject = sSubject;
    oMsg.Body = sBody;
    oMsg.BodyFormat = MailFormat.Text;

    SmtpMail.SmtpServer = "localhost";
    SmtpMail.Send(oMsg);
    return true;
    }
    catch (Exception ex)
    {
    System.Diagnostics.Debug.WriteLine(ex.Message);
    return false;
    }

    }
     
  2. Panic over,
    It's a bit weird really but it was to do with the email address. The address I was trying to send to was a forwarded address on my domain. Once I changed it to one outside my domain everything was fine...
     
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