I just recently bought my own server with IIS7, and I'm trying to set up SMTP so that I can send an e-mail from my website.

Here's my smtp settings:

![enter image description here](https://i.stack.imgur.com/v8jwh.png)

Here is my code that sends the e-mail:

```
private static void SendEmail(IEnumerable<MailAddress> to,
    IEnumerable<MailAddress> bcc, MailAddress from,
    string subject, string bodyHtml)
    {
        var mail = new MailMessage { From = from, Subject = subject,
            Body = bodyHtml, IsBodyHtml = true };

        foreach (var address in to)
        {
            mail.To.Add(address);
        }

        foreach (var address in bcc)
        {
            mail.Bcc.Add(address);
        }

        try
        {
            string server = ConfigurationManager.AppSettings["SMTPServer"];
            int port = Int32.Parse(ConfigurationManager.AppSettings["SMTPPort"]);

            var smtp = new SmtpClient
                           {
                               Host = server,
                               Port = port
                           };

            smtp.Send(mail);
        }
        catch (Exception err)
        {
        }
    }

```

And my config settings:

```
<add key="SMTPServer" value="localhost" />
<add key="SMTPPort" value="25" />

```

I get an error at `smtp.Send(mail);` that says:

> 
> **Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.**
> 
> 
> 

Well, I have no authentication requirements on my smtp server, it says so in my settings in the screenshot.

I looked around, and other people had this problem if they were sending the e-mail from a different e-mail specified in their settings, but I'm sending mine from `info@mysite.com`. I am sending it to an `@gmail.com` account though, so it is sending to a non-local e-mail address.

What am I doing wrong here?