gistにsendgmail.rbを足しました。smtp.gmail.comでメールを送ります。 http://gist.github.com/86778 Rubyで日本語のメールを送る。 - こせきの技術日記
なるべく少ないライブラリで正しい日本語のメールを送る方法について。 結論 先に結論から。 require "nkf" require "net/smtp" def sendmail(from, to, subject, body, host = "localhost", port = 25) body = <<EOT From: #{from} To: #{to.to_a.join(",\n ")} Subject: #{NKF.nkf("-WMm0", subject)} Date: #{Time::now.strftime("%a, %d %b %Y %X %z")} Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit #{NKF.nkf("-Wj
エラー処理をしていませんが、とりあえず。 メールボックスにたまっているメールを、一通ずつパイプで外部コマンドに渡して処理します。処理の終わったメールは削除します。 Perl (Net::POP3) 最近はレンタルサーバーでもlibnetのモジュール群がインストールされていることが多いと思うので、多分モジュールの追加無しで使えると思います。 POP over SSL対応するには、Net::POP3オブジェクト生成時に、ホスト名ではなくIO::Socket::SSLオブジェクトを渡せばいい、らしいです。この場合、IO::Socket::SSLのインストールが必要です。内部で使っているNet::SSLeayはコンパイルが必要なので、レンタルサーバーだとサーバーで用意されていなければSSL対応は諦めるしかないかな? #!/usr/local/bin/perl use strict; use war
はじめに 本稿ではRubyを使ってシンプルなPOP3サーバを作成します。 POP3は、いわゆる「メールの受信」のときに使われるプロトコル(通信規約)です。本稿では、このPOP3でサービスを提供するサーバの作成を通じて、以下のことを学びます。ネットワークプログラミングの基礎POP3の仕組みRubyによるネットワークプログラミングRubyによるUNIXシステムプログラミング POPdの概要 本稿で作成するPOP3サーバ(POPd)は、イントラネットなどの信頼できるネットワークを前提として作成します。そのため、セキュリティへの配慮は最低限にとどめ、できるだけシンプルな構造を心掛けます。ただし「最低限の配慮」として、パスワードが平文で流れないようにするため、POP3の中でも特にAPOPという認証方法を用います。 また、速度やメモリ容量に関してもあまり配慮しません。せいぜい数人から数十人が日常的に使
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く