diff --git a/Idno/Core/Email.php b/Idno/Core/Email.php index e77110797e..a286949826 100644 --- a/Idno/Core/Email.php +++ b/Idno/Core/Email.php @@ -115,6 +115,21 @@ function setHTMLBodyFromTemplate($template_name, $vars = array()) return $this->setHTMLBody($body); } + + /** + * Set the text only component of an email. + * @param type $template_name + * @param type $vars + * @return mixed + */ + function setTextBodyFromTemplate($template_name, $vars = array()) + { + $t = clone site()->template(); + $t->setTemplateType('email-text'); + $body = $t->__($vars)->draw($template_name); + + return $this->setTextBody($body); + } /** * Sets the plain text body of the message diff --git a/Idno/Entities/Invitation.php b/Idno/Entities/Invitation.php index 9ddef0fddf..bcf4016bd5 100644 --- a/Idno/Entities/Invitation.php +++ b/Idno/Entities/Invitation.php @@ -63,6 +63,7 @@ function sendToEmail($email) $message->addTo($email); $message->setSubject(\Idno\Core\site()->session()->currentUser()->getTitle() . " has invited you to join " . \Idno\Core\site()->config()->title . '!'); $message->setHTMLBodyFromTemplate('account/invite', array('email' => $email, 'code' => $this->code, 'inviter' => \Idno\Core\site()->session()->currentUser()->getTitle())); + $message->setTextBodyFromTemplate('account/invite', array('email' => $email, 'code' => $this->code, 'inviter' => \Idno\Core\site()->session()->currentUser()->getTitle())); return $message->send(); } diff --git a/Idno/Entities/User.php b/Idno/Entities/User.php index 096ee86500..85788e74ee 100644 --- a/Idno/Entities/User.php +++ b/Idno/Entities/User.php @@ -102,6 +102,7 @@ static function registerEvents() $email = new Email(); $email->setSubject($eventdata['message']); $email->setHTMLBodyFromTemplate($eventdata['message_template'], $vars); + $email->setTextBodyFromTemplate($eventdata['message_template'], $vars); $email->addTo($user->email); $email->send(); } diff --git a/Idno/Pages/Account/Password.php b/Idno/Pages/Account/Password.php index 716ff754a4..3a3c98cd93 100644 --- a/Idno/Pages/Account/Password.php +++ b/Idno/Pages/Account/Password.php @@ -51,6 +51,7 @@ function postContent() $email->setSubject("Password reset"); $email->addTo($user->email); $email->setHTMLBody($t->__(array('email' => $email_address, 'code' => $auth_code))->draw('account/password')); + $email->setTextBodyFromTemplate('account/password', array('email' => $email_address, 'code' => $auth_code)); $email->send(); $this->forward(\Idno\Core\site()->config()->getURL() . 'account/password/?sent=true'); diff --git a/Idno/Pages/Admin/EmailTest.php b/Idno/Pages/Admin/EmailTest.php index 571e54fdf5..f91d51f482 100644 --- a/Idno/Pages/Admin/EmailTest.php +++ b/Idno/Pages/Admin/EmailTest.php @@ -20,6 +20,7 @@ function postContent() $message->addTo($email); $message->setSubject("Test email from " . \Idno\Core\site()->config()->title . '!'); $message->setHTMLBodyFromTemplate('admin/emailtest'); + $message->setTextBodyFromTemplate('admin/emailtest'); if ($message->send()) { \Idno\Core\site()->session()->addMessage("Test email sent to $email"); diff --git a/Idno/Pages/Admin/Export/Generate.php b/Idno/Pages/Admin/Export/Generate.php index 8eca43e6b2..58beec9b59 100644 --- a/Idno/Pages/Admin/Export/Generate.php +++ b/Idno/Pages/Admin/Export/Generate.php @@ -72,6 +72,7 @@ function postContent() $mail = new Email(); $mail->setHTMLBodyFromTemplate('admin/export'); + $mail->setTextBodyFromTemplate('admin/export'); $mail->addTo(\Idno\Core\site()->session()->currentUser()->email); $mail->setSubject("Your data export is ready"); $mail->send(); diff --git a/Idno/Pages/Admin/Import.php b/Idno/Pages/Admin/Import.php index 32b559987f..3c9b29ea04 100644 --- a/Idno/Pages/Admin/Import.php +++ b/Idno/Pages/Admin/Import.php @@ -66,6 +66,7 @@ function postContent() if ($imported) { $mail = new Email(); $mail->setHTMLBodyFromTemplate('admin/import'); + $mail->setTextBodyFromTemplate('admin/import'); $mail->addTo(\Idno\Core\site()->session()->currentUser()->email); $mail->setSubject("Your data import has completed"); $mail->send(); diff --git a/templates/email-text/account/invite.tpl.php b/templates/email-text/account/invite.tpl.php new file mode 100644 index 0000000000..3203d17945 --- /dev/null +++ b/templates/email-text/account/invite.tpl.php @@ -0,0 +1,12 @@ +Join us! +======= + +Hi there! Your friend ** has invited you to join config()->title?>: config()->getDisplayURL()?>. + +You can use this space to publish your stories, share things that interest you, and discuss things that matter. + +Get started with *config()->title?>* by setting up your account. + +Sign up now: config()->getDisplayURL()?>account/register/?email=&code= + +If you have any questions at all, please don't hesitate to contact us by sending an email to config()->from_email?> diff --git a/templates/email-text/account/password.tpl.php b/templates/email-text/account/password.tpl.php new file mode 100644 index 0000000000..8c2d39c26e --- /dev/null +++ b/templates/email-text/account/password.tpl.php @@ -0,0 +1,8 @@ +Forgot your password? +===================== + +We heard you forgot your password. Don't worry. It happens to the best of us. + +You can reset your password by clicking the link below (or copy and paste it into your browser). + +config()->getDisplayURL() ?>account/password/reset/?email=&code= \ No newline at end of file diff --git a/templates/email-text/admin/emailtest.tpl.php b/templates/email-text/admin/emailtest.tpl.php new file mode 100644 index 0000000000..e8911fe01c --- /dev/null +++ b/templates/email-text/admin/emailtest.tpl.php @@ -0,0 +1,6 @@ +Test Email +========== + +If you can read this, it means that your email settings are configured correctly! + +Visit your site: config()->getDisplayURL()?> diff --git a/templates/email-text/admin/export.tpl.php b/templates/email-text/admin/export.tpl.php new file mode 100644 index 0000000000..5ff4b6b013 --- /dev/null +++ b/templates/email-text/admin/export.tpl.php @@ -0,0 +1,6 @@ +Your data is ready! +=================== + +We've gathered all your site content and placed it in an archive for you. To go get it, click the following link: + +Get your data: config()->getDisplayURL()?>admin/export/ diff --git a/templates/email-text/admin/import.tpl.php b/templates/email-text/admin/import.tpl.php new file mode 100644 index 0000000000..68bdfd9477 --- /dev/null +++ b/templates/email-text/admin/import.tpl.php @@ -0,0 +1,7 @@ +Your data is ready! +=================== + +We've taken the data you supplied and turned it into Known posts! Photos that you had previously +uploaded to the service and embedded into your posts have also been imported. + +Visit your site: config()->getDisplayURL()?> diff --git a/templates/email-text/content/notification/like.tpl.php b/templates/email-text/content/notification/like.tpl.php new file mode 100644 index 0000000000..80755a0c38 --- /dev/null +++ b/templates/email-text/content/notification/like.tpl.php @@ -0,0 +1,3 @@ +Hi! We wanted to let you know that ** liked the post *getNotificationTitle()?>*
+ +View post: getDisplayURL()?> diff --git a/templates/email-text/content/notification/reply.tpl.php b/templates/email-text/content/notification/reply.tpl.php new file mode 100644 index 0000000000..55ffceb7c7 --- /dev/null +++ b/templates/email-text/content/notification/reply.tpl.php @@ -0,0 +1,18 @@ +Hi! We wanted to let you know that ** replied to the post *getNotificationTitle()?>*. + +Here's what they said: + +> #i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?> + + + + View post: getDisplayURL()?> + \ No newline at end of file diff --git a/templates/email-text/content/notification/rsvp.tpl.php b/templates/email-text/content/notification/rsvp.tpl.php new file mode 100644 index 0000000000..5555125a43 --- /dev/null +++ b/templates/email-text/content/notification/rsvp.tpl.php @@ -0,0 +1,17 @@ +Hi! We wanted to let you know that ** RSVPed to the event *getNotificationTitle()?>*. + +Here's what they said: + +> #i', "\n> ", str_replace("\n", "\n> ", $vars['content']))); ?> + + +View post: getDisplayURL()?> + \ No newline at end of file diff --git a/templates/email-text/content/notification/share.tpl.php b/templates/email-text/content/notification/share.tpl.php new file mode 100644 index 0000000000..96212bae8a --- /dev/null +++ b/templates/email-text/content/notification/share.tpl.php @@ -0,0 +1,3 @@ +Hi! We wanted to let you know that ** reshared the post *getNotificationTitle()?>* + +View post: getDisplayURL()?>