Results 1 to 14 of 14

Thread: Sending Email with Auth

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Sending Email with Auth

    Hello
    I have a problem with one application, the application send emails to notify the users of some events that occur. The application works just fine when the user it's connected by wire, but when it's wireless the emails can't be sent.

    I did a little research and i found out that the server just allow to send email messages from the users authenticated, the wireless LAN doesn't authenticate the users...

    So how can i set the credentials/authenticate myself in the server when I'm connected by wireless, to be able to send emails?

    Thanks

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  2. #2

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    Bump

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Sending Email with Auth

    You should provide the code
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  4. #4
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    Here's a nice example showing how to set credentials: How do I authenticate to send an email?

  5. #5

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    This is the current code, it works fine with wired connections:

    vb.net Code:
    1. Dim smtpCliente As New SmtpClient(My.Settings.SmtpServer, My.Settings.SmtpPort)
    2. smtpCliente.Credentials = New Net.NetworkCredential(My.Settings.AD_User, My.Settings.AD_Password) 'Doesnt make any difference
    3. smtpCliente.DeliveryMethod = SmtpDeliveryMethod.Network
    4. smtpCliente.Send(emailToSend)

    In the code I set the credentials, but looks like they aren't used, if i remove the code line it sends the email anyway...

    @MattP
    Can't open the link...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  6. #6
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    The link is to http://systemnetmail.com/faq/4.2.aspx.

    Try setting smtpCliente.UseDefaultCredentials to False before setting smtpCliente.Credentials. I seem to remember that not doing this messes up sending the "AUTH login" command.

  7. #7

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    Doesn't work.
    The message it's something like unable to relay 'email'...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  8. #8
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    I'm assuming it's some sort of 550 5.7.1 error.

    Since you're providing credentials my best guess would be that the smtp service has granted rights to specific subnets that are allowed to relay. Have your administrator check if the wireless segment is granted access.

    If it comes down to it I've had situations where I couldn't get relay access for an smtp server and had to use the SpecifiedPickupDirectory delivery method.

    Code:
    smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory
    smtp.PickupDirectoryLocation = "\\server\c$\Inetpub\mailroot\pickup"

  9. #9

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    Thanks once again.
    No the wireless subnet doesn't have access, it's company policy, so how could i validate the user by the code and send the email?
    I already looked to the DeliveryMethod and the PickupDirectory but i don't understand how can it help me.

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  10. #10
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    Authenticating won't help anything if the subnet you're coming from doesn't have relay access. I had the same situation in the past and had to use the pickup directory.

    You need to make sure that the credentials you're providing can access the pickup directory. If you're using the Windows SMTP service it's C:\Inetpub\mailroot\pickup. You just need a share on the server that you have write access to with your credentials.

    When you send the email using this delivery method you'll actually be writing a file to that location and then the smtp service has a filewatcher that picks it up. The advantage here is that the server is picking it up locally and thus the address that it's using for the relay is its own.

  11. #11

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    Thanks for all the info.
    Just another question, how does outlook works? I can send and receive emails normally...

    This question it's a little bit out of scope, but i'm curious...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  12. #12
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    Quote Originally Posted by mickey_pt View Post
    Thanks for all the info.
    Just another question, how does outlook works? I can send and receive emails normally...

    This question it's a little bit out of scope, but i'm curious...
    I'm not quite sure what you're asking here.

  13. #13

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Sending Email with Auth

    HEhhe
    What I'm asking, how does MSOutlook (email client used in my company), works?
    The users are connected to the lan wireless, and they can send emails without any problem, how does Outlook "bypass" the relay question wireless, pickup directory??

    I hope this time i made myself clear.

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  14. #14
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Sending Email with Auth

    Honestly I'm not sure. It may be that Outlook is using TLS or ImplicitSSL which aren't available in SmtpClient.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width