Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

SMTP authentication is required' When IIS configured to send via localhost

Hi All,

I am using the attached mailing script and configured IIS for this domain to use localhost to send email but still get the error:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: SMTP authentication is required.

Now I don't know if this error is caused by my code or whether its an IIS settign that I have overklooked.

Could you provide any suggestions?

Thanks,

Rit

WEB.CONFIG
<system.net>
        <mailSettings>
            <smtp deliveryMethod="Network">
                <network host="127.0.0.1" port="25" defaultCredentials="false" />
            </smtp>


EMAIL FUNCTION


public static void SendHTMLMessage(string strEmailTemplate, string strSubject, string strFromAddress, string strFromAlias, string strToAddress)
    {
        SmtpClient mySmtpClient = new SmtpClient();
        MailAddress from = new MailAddress(strFromAddress, strFromAlias);
        MailAddress to = new MailAddress(strToAddress);
        MailMessage message = new MailMessage(from, to);
        message.BodyEncoding = Encoding.ASCII;
        message.IsBodyHtml = true;
        message.Subject = strSubject;
        message.Body = strEmailTemplate;
        mySmtpClient.Send(message);
    }

        </mailSettings>
    </system.net>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of gaurav05
gaurav05
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1
rito1

ASKER

Hi

From what I understand talking with our hosts, the server has been configured as an SMTP server and it doesn't need to be authenticated as emails can only be sent  from the server.

Rit
hi,

you need to put smtp servers ip address in relay list and in connection control of SMTP server.

SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1

ASKER

Hi All,

It turns out that the SMTP server uses port 26 instad of 25!

Thanks for you help anyway.

Rit