LoginSignup
26

More than 5 years have passed since last update.

VirtualBoxの仮想マシンから外部にメールを送信する方法

Last updated at Posted at 2014-06-17

仮想マシンから外部(例えば自分のgmailアカウント)あてにメールを送信しようとすると失敗することがあります。

私の場合、自宅の仮想マシンからメールを送信するとこのようにGoogleのサーバから拒否されてしまいました。

$ tail /var/log/maillog
Jun 17 10:23:33 local postfix/smtp[11147]: connect to alt2.aspmx.l.google.com[74.125.137.26]:25: Connection timed out
Jun 17 10:23:58 local postfix/smtp[11119]: connect to aspmx3.googlemail.com[74.125.137.27]:25: Connection timed out
Jun 17 10:23:58 local postfix/smtp[11121]: connect to aspmx4.googlemail.com[173.194.76.27]:25: Connection timed out
Jun 17 10:24:03 local postfix/smtp[11147]: connect to aspmx2.googlemail.com[74.125.142.27]:25: Connection timed out
Jun 17 10:24:28 local postfix/smtp[11119]: connect to aspmx5.googlemail.com[74.125.131.26]:25: Connection timed out
Jun 17 10:24:28 local postfix/smtp[11119]: 5CA4B400CDF: to=<example@gmail.com>, relay=none, delay=866, delays=715/0.02/151/0, dsn=4.4.1, status=deferred (connect to a
spmx5.googlemail.com[74.125.131.26]:25: Connection timed out)
Jun 17 10:24:28 local postfix/smtp[11121]: connect to aspmx5.googlemail.com[74.125.131.27]:25: Connection timed out

これは、おそらく仮想マシン側で設定したHostnameが、DNSの逆引き結果と一致していないからだと思われます。

対処法

自宅が契約してるISPのsmtpサーバ経由で送信するとうまく行きました。
私の場合、仮想マシン上のPostfix設定ファイル(/etc/main.cf)をいじって、

relayhost = [castle.ocn.ne.jp]:25

とするだけで送信できました。

お使いのプロバイダによってはsmtp_authだとかもっといろいろな設定が必要かもしれません。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26