memo.xight.org - 2009-05-24

2009-05-24 Sun

DrupalのTextileモジュールのインストール

- Summary
Textileモジュールのインストールと有効化について。
対象ファイルを展開して、インストールだけでは有効にならない。

- Textileモジュールの配置

% tar xzvf textile-x.x.x.tar.gz
% mv textile /path/to/drupal/modules



- classTextile.php をダウンロードして配置
INSTALL.txtに書いているURLに当該ファイルが存在しなかったので、
以下URLから入手。
http://textpattern.googlecode.com/svn/releases/4.0.8/source/textpattern/lib/classTextile.php

/path/to/drupal/modules/textile/classTextile.php に配置

- 入力書式の追加
http://example.com/path/to/drupal/admin/settings/filters/add
Textileフィルタのみ有効にする。

- コンテンツへの適用
入力書式から Textileを指定する。

- Reference
Textile | drupal.org
http://drupal.org/project/textile

Textile
http://textile.thresholdstate.com/

textpattern - Google Code
http://code.google.com/p/textpattern/

EmojiPrint - Thunderbirdで絵文字を表示するアドオン

- Summary
Thunderbirdで、携帯から送られてきた絵文字を、
正しく表示することができるようになるアドオン。
DoCoMo、au、Softbank、Willcomに対応。

- Reference
EmojiPrint
http://www.takaaki.info/addon/emojiprint/

Thunderbirdで携帯メールの絵文字を表示するアドオンを作りました - mizuno_takaakiの日記
http://d.hatena.ne.jp/mizuno_takaaki/20090426/1240756028

GmailのSMTPでメールを送信した際のFromヘッダ上書き対策

- Summary
GmailのSMTPを利用してメールを送信した際、
Fromを指定していても、Gmailのアカウント名で上書きされる。

- 対策方法 その1
Gmailの設定から「アカウントの設定」にて、「他のメールアドレスを追加」として登録
Fromが一致すればよい。

- 対策方法 その2
Google Appsで当該ドメインのアカウントを作成。

- Reference
Google Apps
http://www.google.com/a/help/intl/ja/

Postfix で、Gmail にメールをリレーする - 私の二次記憶
http://d.hatena.ne.jp/ayokoyama/20061207/p1

PostfixからGmail経由でメールを送る方法

- Summary
OB25P (Outbound Port 25 Blocking) 対策でメールの送信設定が必要。
手動でPOP before SMTPに対応するのも手間。
MTAを設定して、GmailのSMTPを利用することにする。

- /etc/postfix/main.cf

# GmailのSMTPサーバを指定
relayhost = [smtp.gmail.com]:587

# TLSにより暗号化
smtp_use_tls = yes

# plain方式の SMTP AUTH認証を有効にする
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain

# GmailのTLS証明書の妥当性確認のための設定
smtp_tls_CApath = /etc/pki/tls/certs/ca-bundle.crt



- /etc/postfix/sasl_passwdを作成

[smtp.gmail.com]:587 username@gmail.com:password



- /etc/postfix/sasl_passwdの権限変更

# chown root:root /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd



- hash形式の /etc/postfix/sasl_passwd.dbを作成

# postmap /etc/postfix/sasl_passwd


- postfixの再起動

# /etc/init.d/postfix restart


- Gmail SMTP サーバーの証明書を正しく検証する
Gmail SMTP サーバーが持っている証明書から、ルート CA を調べる。
上記の openssl s_client セッションから、Thawte Premium Server CA がルート CA だと分かる。

ルート CA のインターネットドメイン thawte.com のルート証明書をダウンロード。
http://www.thawte.com/roots/ からダウンロード
/usr/share/ca-certificates/thawte.com/ 内に展開。

/etc/postfix/main.cf を編集

/usr/share/ca-certificates/thawte.com/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem



- 注意点
From が自分のGmailアカウントで上書きされる。
送信メールが"送信済みメール"フォルダに配置される。

- Reference
linux.matchy.net - 2008-07-24 - Postfix から Gmail 経由でメールを送る
http://linux.matchy.net/archives/35

Postfix で、Gmail にメールをリレーする - 私の二次記憶
http://d.hatena.ne.jp/ayokoyama/20061207/p1

PHPMailerでGmailのSMTPを利用する

- Summary
PHPMailerでGmailのSMTPを利用してメールを送信する。
ポート465からSMTP over SSLを利用する。

- Source

<?php
mb_language("japanese");
mb_internal_encoding("UTF-8");
 
require("class.phpmailer.php");
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.gmail.com:465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'user@gmail.com';  // Gmailのアカウント名
$mailer->Password = 'gmail_password';  // Gmailのパスワード
$mailer->From     = 'from@gmail.com';  // Fromのメールアドレス
$mailer->FromName = mb_encode_mimeheader(mb_convert_encoding("Fromの名前","JIS","UTF-8"));
$mailer->Subject  = mb_encode_mimeheader(mb_convert_encoding("メールのタイトル","JIS","UTF-8"));
$mailer->Body     = mb_convert_encoding("メールの内容","JIS","UTF-8");
$mailer->AddAddress('friend@example.com'); // 宛先
// $mailer->AddReplyTo($email, $from);
 
if(!$mailer->Send()) {
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
} else {
   echo "Message has been sent";
}
?>


- Reference
tishon.net - Using PHPMailer with Gmail
http://www.tishon.net/index.php/2008/03/21/phpmailer-gmail/

さぼてん - 2009-02-14 - メールフォーム - PHPmailer+xajax
http://saboten009.blogspot.com/2009/02/phpmailerxajax.html

PEAR::MailでGmailのSMTPを利用する

- Summary
Pear::MailでGmailのSMTPを利用してメールを送信する。
ポート587からSTARTTLSを利用する。

- Source

<?php
mb_language("japanese");
mb_internal_encoding("UTF-8");
 
require_once 'Mail.php';
 
$params = array(
  'host'     => 'smtp.gmail.com',
  'port'     => 587,
  'auth'     => true,
  'username' => 'example@gmail.com',
  'password' => 'password',
  'debug'    => true,
);
 
$headers = array(
  'From'    => 'example@gmail.com',
  'To'      => 'example@gmail.com',
  'Subject' => mb_encode_mimeheader(mb_convert_encoding("メールのタイトル","JIS","UTF-8"))
);
 
$recipients = 'example@gmail.com';
$body = mb_convert_encoding("メールの内容","JIS","UTF-8");
 
$smtp = Mail::factory('smtp', $params);
$e = $smtp->send($recipients, $headers, $body);
 
if ( PEAR::isError($e) ) echo $e->getMessage() . "\n";
?>


- Reference
たら風呂 - 2007-04-04 - PEAR::MailでGmailのSMTPを使う
http://d.hatena.ne.jp/taraburo/20070404/1175694545