From 594811350c67feede35d50f05a9e1311b8c4c036 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 19 Jul 2008 16:26:25 -0400 Subject: email settings for post by email darcs-hash:20080719202625-84dde-52b3d6710302f55e35ef57ea0aa4aff07cbeafaa.gz --- lib/mail.php | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'lib/mail.php') diff --git a/lib/mail.php b/lib/mail.php index f852f385a..21a1c7a8f 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -48,13 +48,21 @@ function mail_send($recipients, $headers, $body) { return true; } +function mail_domain() { + $maildomain = common_config('mail', 'domain'); + if (!$maildomain) { + $maildomain = common_config('site', 'server'); + } + return $maildomain; +} + function mail_notify_from() { - global $config; - if ($config['mail']['notifyfrom']) { - return $config['mail']['notifyfrom']; - } else { - return $config['site']['name'] . ' '; + $notifyfrom = common_config('mail', 'notifyfrom'); + if (!$notifyfrom) { + $domain = mail_domain(); + $notifyfrom = common_config('site', 'name') .' '; } + return $notifyfrom; } function mail_to_user(&$user, $subject, $body, $address=NULL) { @@ -121,3 +129,31 @@ function mail_subscribe_notify($listenee, $listener) { mail_send($recipients, $headers, $body); } } + +function mail_new_incoming_notify($user) { + + $profile = $user->getProfile(); + $name = $profile->getBestName(); + + $headers['From'] = $user->incomingemail; + $headers['To'] = $name . ' <' . $user->email . '>'; + $headers['Subject'] = sprintf(_('New email address for posting to %s'), + common_config('site', 'name')); + + $body = sprintf(_("You have a new posting address on %1\$s.\n\n". + "Send email to %2\$s to post new messages.\n\n". + "More email instructions at %3\$s.\n\n". + "Faithfully yours,\n%4\$s"), + common_config('site', 'name'), + $user->incomingemail, + common_local_url('doc', array('title' => 'email')), + common_config('site', 'name')); + + mail_send($user->email, $headers, $body); +} + +function mail_new_incoming_address() { + $prefix = common_good_rand(8); + $suffix = mail_domain(); + return $prefix . '@' . $suffix; +} -- cgit v1.2.3-54-g00ecf