Skip to main content
The question is not about email/MTA server named "Sendmail".
Link
Source Link
Ton
  • 9.9k
  • 16
  • 68
  • 113

Send email from powershell command line with credentials

I am trying to send an email from my gmail ccoiunt in just one single line using windows 8 and powersell. This is the code I use:

Send-MailMessage -smtpServer 'smtp.gmail.com' -port 587 -from '[email protected]' -to '[email protected]' -subject 'Test' -body 'Body' –UseSsl 

But I don't know how to add the credentials. How can I add username and password to this single code line? (there is no need to encrypt the password).

Thanks