# Send Email ## Using curl to send email ### Google Create app passwords https://support.google.com/accounts/answer/185833?hl=en ### Send email ```bash= FROM_EMAIL=myself@gmail.com APP_PASSWORD=**************** TO_EMAIL=xigua@xigua.tw CONTENT="abc" curl \ --ssl-reqd \ --url 'smtps://smtp.gmail.com:465' \ --user "$FROM_EMAIL:$APP_PASSWORD" \ --mail-from $FROM_EMAIL \ --mail-rcpt $TO_EMAIL \ --upload-file <(echo $CONTENT) ``` ### Bash script ```bash= # ~/send_email.sh # 自己的 Gmail FROM_EMAIL=$1 # Google 的應用程式密碼 APP_PASSWORD=$2 # 收件人 TO_EMAIL=$3 # 信件內容 CONTENT=$4 curl \ # --ssl-reqd 強制使用 SSL/TLS --ssl-reqd \ # 指定 Gmail SMTP Server 的 URL --url 'smtps://smtp.gmail.com:465' \ # 登入 Gmail SMTP 的帳號密碼 --user "$FROM_EMAIL:$APP_PASSWORD" \ # 寄件人 --mail-from $FROM_EMAIL \ # 收件人 --mail-rcpt $TO_EMAIL \ # 使用 Process Substitution 發送 email 的文字內容 --upload-file <(echo $CONTENT) ```  ### Crontab ```bash= chmod +x ./send_email.sh crontab -e ``` 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up