Simply getting "Failure to send email"

Discussion in 'Email' started by thephoenix007, Sep 13, 2015.

  1. public Emailer(User user)
    {
    this.User = user;
    this.Client = new SmtpClient("mail.mydomain.com");
    this.Client.UseDefaultCredentials = false;

    }

    public string SendActivationEmail()
    {
    try
    {
    this.Client.Credentials = new NetworkCredential("UserRegistration", "password");
    MailDefinition md = new MailDefinition();
    md.From = "UserRegistration@mydomain.com";
    md.Subject = string.Format("{0}, Welcome to domain.com! Please activate your account.", this.User.UserName);
    md.IsBodyHtml = true;
    md.BodyFileName = "~/Utilities/Email/EmailConfirmationTemplate.html";
    md.EmbeddedObjects.Add(new EmbeddedMailObject("Background", "~/Content/Images/BGPlanet.jpg"));
    md.EmbeddedObjects.Add(new EmbeddedMailObject("Logo", "~/Content/Images/logo.png"));

    ListDictionary replacements = new ListDictionary();
    replacements.Add("{username}", User.UserName);
    replacements.Add("{guid}", User.ConfirmationGuid.ToString());
    replacements.Add("{benderquote}", Fun.GenerateBenderQuote());

    MailMessage message = md.CreateMailMessage("MyRealEmail@gmail.com", replacements, new System.Web.UI.Control());

    Client.Send(message);
    return string.Empty;
    }
    catch (Exception ex)
    {
    return ex.Message;
    }
    }

    So This code works, right up to Client.Send(message); After about 20 seconds I get. "Failure to send message". No exceptions thrown.

    Any Help?
     

Share This Page