Giter Club home page Giter Club logo

Comments (5)

mzur avatar mzur commented on May 30, 2024

I think there is no way for this plugin to force a change of the header without using a new email service. A simple change of the default mail service would make this possible:

email::$services['html-mail'] = function($email) {
   $headers = array(
      'From: ' . $email->from,
      'Reply-To: ' . $email->replyTo,
      'Return-Path: ' . $email->replyTo,
      'Message-ID: <' . time() . '-' . $email->from . '>',
      'X-Mailer: PHP v' . phpversion(),
      // changed:
      'Content-Type: text/html; charset=utf-8',
      'Content-Transfer-Encoding: 8bit',
   );
   ini_set('sendmail_from', $email->from);
   $send = mail($email->to, str::utf8($email->subject), str::utf8($email->body), implode(PHP_EOL, $headers));
   ini_restore('sendmail_from');
   if(!$send) {
      throw new Error('The email could not be sent');
   }
};

The contact form plugin then would need a new option to set the email service manually.

@chrisbalt would you be happy with this solution? You could make this work right now if you added the above email service and called it mail, thus overwriting the default service.

from kirby-uniform.

chrisbalt avatar chrisbalt commented on May 30, 2024

@mzur I think you're right, it seems that either modifying the existing service–or adding a new service adopter–with the Content-Type properly set is the only way to go. Could instrument a somewhat-elegant solution if a new mail service could be defined outside of the Kirby toolkit. Could then detect some string (like "html") in the snippet filename, which would trigger use of the html-mail service. Until then, this works just fine.

Thanks for the response.

from kirby-uniform.

mzur avatar mzur commented on May 30, 2024

An option to choose a (custom) email service will be added in v1.3 (#11).

from kirby-uniform.

xu-chris avatar xu-chris commented on May 30, 2024

👍 @mzur You should add this to the plugin and/or to the README.md!

from kirby-uniform.

mzur avatar mzur commented on May 30, 2024

I think it's rather for the Toolkit to implement this and allow different content types with the mail service or provide a new html-mail service. Feel free to request this feature 😉

from kirby-uniform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.