The defendant said he bought it online from a Dutch website to help treat his depression.
The website allegedly said it was legal in New Zealand and it could be imported to this country.
Through counsel Hugo Young, the man sought a discharge without conviction.
Young submitted the offending was at the lowest end of the scale, the amount involved was small and he had "genuine reasons" to purchase the drug, which he had done so before, legally, in other jurisdictions.
Police were opposed to the discharge but accepted the defendant had "significant" mental health challenges and were not opposed to name suppression being granted.
Judge Farnan ultimately found the gravity of his offending to be in the lower category and said a conviction would exacerbate his already ''serious'' mental health issues.
Other consequences included impacts on his current and future employment.
Judge Farnan granted the discharge, however, she ordered the man to make a $500 donation to the Salvation Army and pay $130 court costs.
Where to get help:
• Lifeline: 0800 543 354 (available 24/7)
• Suicide Crisis Helpline: 0508 828 865 (0508 TAUTOKO) (available 24/7)
• Youth services: (06) 3555 906
• Youthline: 0800 376 633
• Kidsline: 0800 543 754 (available 24/7)
• Whatsup: 0800 942 8787 (1pm to 11pm)
• The Word
• Depression helpline: 0800 111 757 (available 24/7)
• Rainbow Youth: (09) 376 4155
• CASPER Suicide Prevention
If it is an emergency and you feel like you or someone else is at risk, call 111.