diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-07-19 16:26:25 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-07-19 16:26:25 -0400 |
commit | 594811350c67feede35d50f05a9e1311b8c4c036 (patch) | |
tree | f97ad0af92be3533ce38428d93129ca1b8869450 /lib/mail.php | |
parent | 1d7450ca16cc210ea0ed4a7f68f2e6bff83b00fa (diff) |
email settings for post by email
darcs-hash:20080719202625-84dde-52b3d6710302f55e35ef57ea0aa4aff07cbeafaa.gz
Diffstat (limited to 'lib/mail.php')
-rw-r--r-- | lib/mail.php | 46 |
1 files changed, 41 insertions, 5 deletions
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'] . ' <noreply@'.$config['site']['server'].'>'; + $notifyfrom = common_config('mail', 'notifyfrom'); + if (!$notifyfrom) { + $domain = mail_domain(); + $notifyfrom = common_config('site', 'name') .' <noreply@'.$domain.'>'; } + 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; +} |