Skip to content

Instantly share code, notes, and snippets.

@zh
Created September 18, 2008 04:06
Show Gist options
  • Save zh/11369 to your computer and use it in GitHub Desktop.
Save zh/11369 to your computer and use it in GitHub Desktop.
--- scripts/maildaemon.php 2008-09-18 12:58:39.000000000 +0900
+++ /var/www/laconica/scripts/maildaemon.php.new 2008-09-18 13:01:01.000000000 +0900
@@ -30,6 +30,7 @@
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php');
require_once('Mail/mimeDecode.php');
+require_once('Mail/RFC822.php');
# FIXME: we use both Mail_mimeDecode and mailparse
# Need to move everything to mailparse
@@ -73,12 +74,12 @@
}
function user_from($from_hdr) {
- $froms = mailparse_rfc822_parse_addresses($from_hdr);
- if (!$froms) {
+ $froms = Mail_RFC822::parseAddressList($from_hdr);
+ if (PEAR::isError($froms)) {
return NULL;
}
$from = $froms[0];
- $addr = common_canonical_email($from['address']);
+ $addr = common_canonical_email($from->mailbox . '@' . $from->host);
$user = User::staticGet('email', $addr);
if (!$user) {
$user = User::staticGet('smsemail', $addr);
@@ -88,9 +89,9 @@
function user_match_to($user, $to_hdr) {
$incoming = $user->incomingemail;
- $tos = mailparse_rfc822_parse_addresses($to_hdr);
+ $tos = Mail_RFC822::parseAddressList($to_hdr);
foreach ($tos as $to) {
- if (strcasecmp($incoming, $to['address']) == 0) {
+ if (strcasecmp($incoming, $to->mailbox . '@' . $to->host) == 0) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment