Linux で、あるドメインの MX レコードを調べる方法

あるドメインで運用されているトップのメールサーバ(ルートのメールサーバ、つまり外部と通信する大元のメールサーバのこと)を調べるには、次のようにコマンドを打てばよい。

nslookup -type=mx amazonaws.com

上の例では amazonaws.com のトップのメールサーバ、つまり Amazon Web Services(AWS)の MX レコードを調べている。preference = 10 などのフィールドは、そのサーバの(通信の)優先度を表す。値が等しい場合は優先度は同じ、値が大きくなるほど優先度は低くなる。

あるドメインで運用されているトップのメールサーバ(ルートのメールサーバ、つまり外部と通信する大元のメールサーバのこと)を調べるには、次のようにコマンドを打てばよい。

nslookup -type=mx amazonaws.com

上の例では amazonaws.com のトップのメールサーバ、つまり Amazon Web Services(AWS)の MX レコードを調べている。preference = 10 などのフィールドは、そのサーバの(通信の)優先度を表す。値が等しい場合は優先度は同じ、値が大きくなるほど優先度は低くなる。

bash で、シェルスクリプトからメールを送る方法

bash では、様々なコマンドを`(バッククオーテーション)で囲むと、そのコマンドを変数に入れたりすることができる。つまり、何か処理を始めたり終わったことをメールで通知する場合は次のようにする。

#!/bin/bash

echo 'Subject: Started: your_program'   >  temp.txt
echo 'To: yourname@yourdomain.com'      >> temp.txt
echo 'Started.'                         >> temp.txt
cat  temp.txt                           | `sendmail -t -i`
rm temp.txt

your_program (←ここに処理したいプログラム名(時間がかかるもの)を書く)

echo 'Subject: Completed: your_program' >  temp.txt
echo 'To: yourname@yourdomain.com'      >> temp.txt
echo 'Completed.'                       >> temp.txt
cat temp.txt                            | `sendmail -t -i`
rm  temp.txt

大事なのは
cat temp.txt | `sendmail -t -i`

bash では、様々なコマンドを`(バッククオーテーション)で囲むと、そのコマンドを変数に入れたりすることができる。つまり、何か処理を始めたり終わったことをメールで通知する場合は次のようにする。

#!/bin/bash

echo 'Subject: Started: your_program'   >  temp.txt
echo 'To: yourname@yourdomain.com'      >> temp.txt
echo 'Started.'                         >> temp.txt
cat  temp.txt                           | `sendmail -t -i`
rm temp.txt

your_program (←ここに処理したいプログラム名(時間がかかるもの)を書く)

echo 'Subject: Completed: your_program' >  temp.txt
echo 'To: yourname@yourdomain.com'      >> temp.txt
echo 'Completed.'                       >> temp.txt
cat temp.txt                            | `sendmail -t -i`
rm  temp.txt

大事なのは
cat temp.txt | `sendmail -t -i`

Perl で、メールを送信する方法

open で /usr/sbin/sendmail を開いてそのハンドル SEND を使って print 文で処理する方法もある。
open で /usr/sbin/sendmail を開いてそのハンドル SEND を使って print 文で処理する方法もある。

Perl で、SpamAssassin を使って迷惑メールを処理する。

オープンソースで迷惑メールの処理するソフトといえば SpamAssassin (直訳するとスパム暗殺者)が有名だ。何しろ spamassassin.apache.org というサイト名からも分かるとおり、Apache Foundation 謹製なのだ。 その SpamAssassin、Perl で書かれている。なので当然 Perl のライブラリが用意されており、Perl 使いの人は簡単に自身のプログラム中から呼び出すことができる。SpamAssassin 自体はメールサーバのフロントエンドで、Procmail なんかと一緒に使うことが多いだろうから、あまり自身のプログラム中から呼び出すようなことはないとは思うのだが、何かのときに役に立つかもしれないから、とりあえず以下にサンプルを載せておこう(というかこのサイトのすべての内容自体、自分のためのメモなのでご了承を)。
オープンソースで迷惑メールの処理するソフトといえば SpamAssassin (直訳するとスパム暗殺者)が有名だ。何しろ spamassassin.apache.org というサイト名からも分かるとおり、Apache Foundation 謹製なのだ。 その SpamAssassin、Perl で書かれている。なので当然 Perl のライブラリが用意されており、Perl 使いの人は簡単に自身のプログラム中から呼び出すことができる。SpamAssassin 自体はメールサーバのフロントエンドで、Procmail なんかと一緒に使うことが多いだろうから、あまり自身のプログラム中から呼び出すようなことはないとは思うのだが、何かのときに役に立つかもしれないから、とりあえず以下にサンプルを載せておこう(というかこのサイトのすべての内容自体、自分のためのメモなのでご了承を)。

Requirements for Mobile Phones (English)

I would like to propose the unique requirements for mobile phones. The following items are significant considerations under mobile site development, especially in i-mode phones.
  1. UserAgent type that is, a Browser Name of CGI environments which is sent by a mobile phone to a web server.
  2. Range of IP addresses in each mobile operator, which is required to judge whether a user is using a mobile phone or a PC in order to support both of them in the web site. In Japanese mobile phone operators, they are using their specific proxy servers, which are accompanying with the specific range of IP addresses.
  3. Screen Size of each mobile phone, especially the size of width, which would be found in a CGI environment UserAgent in the latest phones
  4. Image Format such as JPEG, PNG and GIF supported by each mobile phone
  5. Maximum Size of Receiving Bytes per a page
  6. Difference of Handling Colors in each mobile phone
  7. Difference of Smilies (Picture Icons) both in each mobile phone and operator
  8. Name Convention of an E-mail Address in each operator (Japanese i-mode e-mail system violates RFC).
  9. Available Character Set in each operator (Shift-JIS, UTF-8 in Japan)
  10. Available Character Types in each operator (such as ZENKAKU, HANKAKU in Japan)
  11. Available Input Method in each operator (Access-key concept in CHTML)
  12. Support of Native Functions of a mobile phone (i.e. switching a browser screen to an e-mail application with 'mailto:' in CHTML at a single screen of a mobile phone, launching Java application, and directly calling to someone with 'tel:' in CHTML, etc)
  13. Difference in between Official Sites and Unofficial Sites (The acquiring information is different)
  14. Session Management because we cannot use cookie in i-mode phones
I would like to propose the unique requirements for mobile phones. The following items are significant considerations under mobile site development, especially in i-mode phones.
  1. UserAgent type that is, a Browser Name of CGI environments which is sent by a mobile phone to a web server.
  2. Range of IP addresses in each mobile operator, which is required to judge whether a user is using a mobile phone or a PC in order to support both of them in the web site. In Japanese mobile phone operators, they are using their specific proxy servers, which are accompanying with the specific range of IP addresses.
  3. Screen Size of each mobile phone, especially the size of width, which would be found in a CGI environment UserAgent in the latest phones
  4. Image Format such as JPEG, PNG and GIF supported by each mobile phone
  5. Maximum Size of Receiving Bytes per a page
  6. Difference of Handling Colors in each mobile phone
  7. Difference of Smilies (Picture Icons) both in each mobile phone and operator
  8. Name Convention of an E-mail Address in each operator (Japanese i-mode e-mail system violates RFC).
  9. Available Character Set in each operator (Shift-JIS, UTF-8 in Japan)
  10. Available Character Types in each operator (such as ZENKAKU, HANKAKU in Japan)
  11. Available Input Method in each operator (Access-key concept in CHTML)
  12. Support of Native Functions of a mobile phone (i.e. switching a browser screen to an e-mail application with 'mailto:' in CHTML at a single screen of a mobile phone, launching Java application, and directly calling to someone with 'tel:' in CHTML, etc)
  13. Difference in between Official Sites and Unofficial Sites (The acquiring information is different)
  14. Session Management because we cannot use cookie in i-mode phones