Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

31
  • 54
    You can still get user not logged in errors if Google just suddenly decides you have sent too many in the past xx number of minutes. You should always add a trySend, if it errors sleep a while, and then attempt again. Commented Aug 26, 2009 at 6:30
  • 76
    Interesting note: If you swap 'UseDefaultCredentials = false,' and 'Credentials = ...' it won't authenticate. Commented Nov 17, 2009 at 16:56
  • 13
    There are no problems with SPF using this method. Every email client can be configured to do exactly this. You just may get problems if you use your own server (i.e. something else than smtp.gmail.com) with [email protected] as sender. Btw: smtp.gmail.com automatically overwrites the sender address if it's not yours. Commented Mar 18, 2010 at 18:39
  • 25
    I was having a hard time getting this working even with trying various tweaks. As suggested on a related post, I found that it was actually my antivirus that was preventing emails from being successfully sent. The antivirus in question is McAffee, and its "Access Protection" has a "Antivirus Standard Protection" category that has a "Prevent mass mailing worms from sending email" rule. Tweaking / disabling that rule got this code working for me! Commented Aug 5, 2012 at 17:02
  • 20
    I was getting the 5.5.1 Authentication Required error message until I realized I was testing with an account (my personal one) that had two factor authentication turned on. Once I used an account that didn't have that, it worked fine. I could also have generated a password for my application that I was testing from in my personal acct, but I didn't want to do that. Commented Jun 17, 2013 at 16:18