<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gmail on kenji.blog</title><link>http://kenji.blog/en/tags/gmail/</link><description>Recent content in Gmail on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>kenjinote</copyright><lastBuildDate>Thu, 27 Feb 2025 02:13:31 +0900</lastBuildDate><atom:link href="http://kenji.blog/en/tags/gmail/index.xml" rel="self" type="application/rss+xml"/><item><title>Send Gmail from curl</title><link>http://kenji.blog/en/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/</link><pubDate>Thu, 27 Feb 2025 02:13:31 +0900</pubDate><guid>http://kenji.blog/en/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/</guid><description>&lt;img src="http://kenji.blog/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/img.png" alt="Featured image of post Send Gmail from curl" />&lt;h1 id="send-gmail-from-curl">Send Gmail from curl
&lt;/h1>&lt;h2 id="1-get-an-app-password">1. Get an App Password
&lt;/h2>&lt;p>&lt;a class="link" href="https://myaccount.google.com/apppasswords" target="_blank" rel="noopener"
>https://myaccount.google.com/apppasswords&lt;/a>
Click the link above and enter an app name.
Save the generated password.&lt;/p>
&lt;h2 id="2-send-an-email-with-the-curl-command">2. Send an email with the curl command
&lt;/h2>&lt;p>Run the following command.&lt;/p>
&lt;p>In the example below, the email content is written in &lt;code>mail.txt&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mail.txt" data-lang="mail.txt">&lt;span class="line">&lt;span class="cl">From: from@gmail.com
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">To: to@gmail.com
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Subject: Test Email
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Content-Type: text/plain; charset=&amp;#34;UTF-8&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">This is a test email.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Create the above file and run the following command.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl --url &lt;span class="s2">&amp;#34;smtps://smtp.gmail.com:465&amp;#34;&lt;/span> --ssl-reqd --mail-from &lt;span class="s2">&amp;#34;from@gmail.com&amp;#34;&lt;/span> --mail-rcpt &lt;span class="s2">&amp;#34;to@gmail.com&amp;#34;&lt;/span> --user &lt;span class="s2">&amp;#34;from@gmail.com:xxxxxxxxxxxxxxxx&amp;#34;&lt;/span> --upload-file mail.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>Replace xxxxxxxxxxxxxxxx with your app password.&lt;/li>
&lt;/ul></description></item></channel></rss>