curl --ssl-reqd \
--url 'smtps://smtp.gmail.com:465' \
--user '[email protected]:password' \
--mail-from '[email protected]' \
--mail-rcpt '[email protected]' \
--upload-file mail.txt
mail.txt file contents:
From: "User Name" <[email protected]>
To: "John Smith" <[email protected]>
Subject: This is a test
Hi John,
I’m sending this mail with curl thru my gmail account.
Bye!
Additional info:
-
I’m using
curl
version 7.21.6 with SSL support. -
You don’t need to use the
--insecure
switch, which preventscurl
from performing SSL connection verification. See this online resource for further details. -
It’s considered a bad security practice to pass account credentials thru
command line arguments. Use--netrc-file
. See the documentation. -
You must turn on access for less secure apps or the newer App passwords.