2

I'm using C# and on my IIS I'm sending smtp messages (using local host) the server have a SSL certification when people browse to it (https) I wanted to improve the mail sending that is will be Send with SSL so I added this lines :

`client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;`
`client.UseDefaultCredentials = true;`
`client.EnableSsl = true;`

just after creating the client: var client = new System.Net.Mail.SmtpClient("127.0.0.1");

and before: client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

but now when I send the mails I get: "SSL must not be enabled for pickup-directory delivery methods"

Please help :)

0

3 Answers 3

5

you have to set the delivery method to network in your code :

client.DeliveryMethod = SmtpDeliveryMethod.Network;

0

According to the SendAsync method's MSDN page's Exception section, you'll get SmtpException if "EnableSsl is set to true but the DeliveryMethod property is set to SpecifiedPickupDirectory or PickupDirectoryFromIis". For me the DeliveryMethod is set to Network by default (it's a desktop client though). From the error message it seems that it is specific or IIS pickup for you. Is your software desktop or ASP.NET web app? Tell us more. Are you using Send or SendAsync? The "client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;" is redundant, UseDefaultCredentials should do something like that automatically under the hood.

0

I would like to add an extra bit if @badr slaoui solution doesn't work for you. Check your web.config for <mailSettings>, commenting that solved my issue.

<mailSettings>
  <smtp deliveryMethod="SpecifiedPickupDirectory" from="no-reply@global.ca">
    <network host="localhost" port="25" />
            <specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\Pickup" />
  </smtp>
</mailSettings>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.