function moveOldNotificationEmailsToTrash() { var senderEmail = "calendar-notification@google.com"; // Googleカレンダーからの通知のメールアドレスをここに入力 var daysAgo = 3; // 3 日前を指定 // 現在の日付から指定した日数前の日付を取得 var date = new Date(); date.setDate(date.getDate() - daysAgo); var formattedDate = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy/MM/dd"); // 検索クエリ:指定されたメールアドレスと日付以前のメールを取得 var query = 'from:' + senderEmail + ' before:' + formattedDate; // Gmailの検索で条件に合うスレッドを取得 var threads = GmailApp.search(query); // 各スレッドをループし、ゴミ箱に移動 for (var i = 0; i < threads.length; i++) { threads[i].moveToTrash(); } Logger.log(threads.length + " threads moved to trash."); }
/etc/postfix/sasl_passwdというファイルを作成して、gmailの認証情報
[smtp.gmail.com]:587 <メールアドレス>:<アプリパスワード>を書き込む。<メールアドレス>は、hoge@gmail.comでも良いし、hoge@rcnp.osaka-u.ac.jpでも出来た。そして、
sudo chmod 600 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwdで設定する。(このpostmapコマンドが何をしているかはよくわかっていない)
sudo cp -p /etc/postfix/main.cf.proto /etc/postfix/main.cfで /etc/postfix/main.cf というファイルを作成して、 /etc/postfix/main.cf を編集して、
relayhost = [smtp.gmail.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_tls_security_options = noanonymousを末尾に書き加える。 = の右に何も書かれていない変数はコメントアウトする。 そして、
sudo systemctl restart postfixで postfix を再起動。
echo "Hello! World!" | mail -s "Test" <送付先メールアドレス>
echo "こんにちは!" | mail -s "タイトル" --content-type 'text/plain; charset=utf-8' <送付先メールアドレス>
less /var/log/mail.logでエラーログを探す。
sudo dpkg-reconfigure exim4-configとすると対話入力画面が出てくる。
/etc/exim4/passwd.clientを編集。
gmail-smtp.l.google.com:<メールアドレス>:<アプリ パスワード> *.google.com:<メールアドレス>:<アプリ パスワード> smtp.gmail.com:<メールアドレス>:<アプリ パスワード>出来たら、
sudo update-exim4.confで設定を更新。
function doGet() { return ContentService.createTextOutput('Hello World!\n'); }
curl -L https://script.google.com/macros/s/xxxx/execとすればレスポンスが得られる。