trim mail and maildaemon
darcs-hash:20080721042333-84dde-f3331569171b33f16322bd6b2999a21cefb718c0.gz
This commit is contained in:
parent
c2aaa22ffb
commit
184425796b
18
lib/mail.php
18
lib/mail.php
|
@ -123,7 +123,7 @@ function mail_subscribe_notify($listenee, $listener) {
|
||||||
"\t".'%3$s'."\n\n".
|
"\t".'%3$s'."\n\n".
|
||||||
'Faithfully yours,'."\n".'%4$s.'."\n"),
|
'Faithfully yours,'."\n".'%4$s.'."\n"),
|
||||||
$long_name,
|
$long_name,
|
||||||
common_config('site', 'name'),
|
common_config('site', 'name'),
|
||||||
$other->profileurl,
|
$other->profileurl,
|
||||||
common_config('site', 'name'));
|
common_config('site', 'name'));
|
||||||
mail_send($recipients, $headers, $body);
|
mail_send($recipients, $headers, $body);
|
||||||
|
@ -134,12 +134,12 @@ function mail_new_incoming_notify($user) {
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
$name = $profile->getBestName();
|
$name = $profile->getBestName();
|
||||||
|
|
||||||
$headers['From'] = $user->incomingemail;
|
$headers['From'] = $user->incomingemail;
|
||||||
$headers['To'] = $name . ' <' . $user->email . '>';
|
$headers['To'] = $name . ' <' . $user->email . '>';
|
||||||
$headers['Subject'] = sprintf(_('New email address for posting to %s'),
|
$headers['Subject'] = sprintf(_('New email address for posting to %s'),
|
||||||
common_config('site', 'name'));
|
common_config('site', 'name'));
|
||||||
|
|
||||||
$body = sprintf(_("You have a new posting address on %1\$s.\n\n".
|
$body = sprintf(_("You have a new posting address on %1\$s.\n\n".
|
||||||
"Send email to %2\$s to post new messages.\n\n".
|
"Send email to %2\$s to post new messages.\n\n".
|
||||||
"More email instructions at %3\$s.\n\n".
|
"More email instructions at %3\$s.\n\n".
|
||||||
|
@ -148,7 +148,7 @@ function mail_new_incoming_notify($user) {
|
||||||
$user->incomingemail,
|
$user->incomingemail,
|
||||||
common_local_url('doc', array('title' => 'email')),
|
common_local_url('doc', array('title' => 'email')),
|
||||||
common_config('site', 'name'));
|
common_config('site', 'name'));
|
||||||
|
|
||||||
mail_send($user->email, $headers, $body);
|
mail_send($user->email, $headers, $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,16 +159,16 @@ function mail_new_incoming_address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_broadcast_notice_sms($notice) {
|
function mail_broadcast_notice_sms($notice) {
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
|
|
||||||
$user->smsnotify = 1;
|
$user->smsnotify = 1;
|
||||||
$user->whereAdd('EXISTS (select subscriber from subscriptions where ' .
|
$user->whereAdd('EXISTS (select subscriber from subscriptions where ' .
|
||||||
' subscriber = user.id and subscribed = ' . $notice->profile_id);
|
' subscriber = user.id and subscribed = ' . $notice->profile_id);
|
||||||
$user->whereAdd('sms is not null');
|
$user->whereAdd('sms is not null');
|
||||||
|
|
||||||
$cnt = $user->find();
|
$cnt = $user->find();
|
||||||
|
|
||||||
while ($user->fetch()) {
|
while ($user->fetch()) {
|
||||||
mail_send_sms_notice($notice, $user);
|
mail_send_sms_notice($notice, $user);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ function mail_send_notice($notice, $user) {
|
||||||
function mail_confirm_sms($code, $nickname, $address) {
|
function mail_confirm_sms($code, $nickname, $address) {
|
||||||
|
|
||||||
$recipients = $address;
|
$recipients = $address;
|
||||||
|
|
||||||
$headers['From'] = mail_notify_from();
|
$headers['From'] = mail_notify_from();
|
||||||
$headers['To'] = $nickname . ' <' . $address . '>';
|
$headers['To'] = $nickname . ' <' . $address . '>';
|
||||||
$headers['Subject'] = _('SMS confirmation');
|
$headers['Subject'] = _('SMS confirmation');
|
||||||
|
|
|
@ -35,10 +35,10 @@ require_once('Mail/mimeDecode.php');
|
||||||
# Need to move everything to mailparse
|
# Need to move everything to mailparse
|
||||||
|
|
||||||
class MailerDaemon {
|
class MailerDaemon {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_message($fname='php://stdin') {
|
function handle_message($fname='php://stdin') {
|
||||||
list($from, $to, $msg) = $this->parse_message($fname);
|
list($from, $to, $msg) = $this->parse_message($fname);
|
||||||
if (!$from || !$to || !$msg) {
|
if (!$from || !$to || !$msg) {
|
||||||
|
@ -96,11 +96,11 @@ class MailerDaemon {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_command($user, $msg) {
|
function handle_command($user, $msg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function respond($from, $to, $response) {
|
function respond($from, $to, $response) {
|
||||||
|
|
||||||
$headers['From'] = $to;
|
$headers['From'] = $to;
|
||||||
|
@ -109,11 +109,11 @@ class MailerDaemon {
|
||||||
|
|
||||||
return mail_send(array($from), $headers, $response);
|
return mail_send(array($from), $headers, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log($level, $msg) {
|
function log($level, $msg) {
|
||||||
common_log($level, 'MailDaemon: '.$msg);
|
common_log($level, 'MailDaemon: '.$msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_notice($user, $msg) {
|
function add_notice($user, $msg) {
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
$notice->profile_id = $user->id;
|
$notice->profile_id = $user->id;
|
||||||
|
@ -142,12 +142,12 @@ class MailerDaemon {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$notice->query('COMMIT');
|
$notice->query('COMMIT');
|
||||||
common_save_replies($notice);
|
common_save_replies($notice);
|
||||||
common_real_broadcast($notice);
|
common_real_broadcast($notice);
|
||||||
$this->log(LOG_INFO,
|
$this->log(LOG_INFO,
|
||||||
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
|
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_message($fname) {
|
function parse_message($fname) {
|
||||||
$contents = file_get_contents($fname);
|
$contents = file_get_contents($fname);
|
||||||
$parsed = Mail_mimeDecode::decode(array('input' => $contents,
|
$parsed = Mail_mimeDecode::decode(array('input' => $contents,
|
||||||
|
@ -157,13 +157,13 @@ class MailerDaemon {
|
||||||
if (!$parsed) {
|
if (!$parsed) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$from = $parsed->headers['from'];
|
$from = $parsed->headers['from'];
|
||||||
|
|
||||||
$to = $parsed->headers['to'];
|
$to = $parsed->headers['to'];
|
||||||
|
|
||||||
$type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
|
$type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
|
||||||
|
|
||||||
if ($parsed->ctype_primary == 'multitype') {
|
if ($parsed->ctype_primary == 'multitype') {
|
||||||
foreach ($parsed->parts as $part) {
|
foreach ($parsed->parts as $part) {
|
||||||
if ($part->ctype_primary == 'text' &&
|
if ($part->ctype_primary == 'text' &&
|
||||||
|
@ -177,17 +177,17 @@ class MailerDaemon {
|
||||||
} else {
|
} else {
|
||||||
$this->unsupported_type($type);
|
$this->unsupported_type($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($from, $to, $msg);
|
return array($from, $to, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsupported_type($type) {
|
function unsupported_type($type) {
|
||||||
$this->error(NULL, "Unsupported message type: " . $type);
|
$this->error(NULL, "Unsupported message type: " . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_msg($msg) {
|
function cleanup_msg($msg) {
|
||||||
# XXX: signatures
|
# XXX: signatures
|
||||||
# XXX: quoting
|
# XXX: quoting
|
||||||
preg_replace('/\s+/', ' ', $msg);
|
preg_replace('/\s+/', ' ', $msg);
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user