Giter Site home page Giter Site logo

Add mail service about pi HOT 17 CLOSED

pi-engine avatar pi-engine commented on July 24, 2024
Add mail service

from pi.

Comments (17)

voltan avatar voltan commented on July 24, 2024

Other needed option . use and manage mail template ( html and text )

from pi.

taiwen avatar taiwen commented on July 24, 2024

Implemented in commit 369a3f3

from pi.

voltan avatar voltan commented on July 24, 2024

I will test it in contact module. Thanks

from pi.

voltan avatar voltan commented on July 24, 2024

In Mail service -> message function, setTo ( or addTo ) method missing. And it good if add $message->setEncoding($charset);

from pi.

taiwen avatar taiwen commented on July 24, 2024

The service->message() returns a Zend\Message object and it already has the setTo/setEncoding methods.

from pi.

voltan avatar voltan commented on July 24, 2024

I am sorry, I use this method and set other options after return object
thanks

from pi.

taiwen avatar taiwen commented on July 24, 2024

Are we okay to close the issue? @voltan @MarcoXoops

from pi.

voltan avatar voltan commented on July 24, 2024

In localhost ( fedora : php 5.4.14 mysql 5.5.30 apache 2.4 But I am not sure my system mail service work will or not )I have problem whit : mimeMessage function, this part :

        $part = function ($content) use ($this)
        {
            if (is_string($content)) {
                $content = new Mime\Part($content);
            }
            if (is_array($content)) {
                list($data, $type) = $content;
                $content = $this->mimePart($data, $type);
            }
            return $content;
        };

White screen whiteout error. But I don't check on live server .I will check tomorrow

from pi.

taiwen avatar taiwen commented on July 24, 2024

I guess it is caused by using _$this_ directly in anonymous function.

from pi.

voltan avatar voltan commented on July 24, 2024

For test I changed

    public function mimeMessage($parts = array())
    {
        $message = new Mime\Message;
        $part = function ($content) use ($this)
        {
            if (is_string($content)) {
                $content = new Mime\Part($content);
            }
            if (is_array($content)) {
                list($data, $type) = $content;
                $content = $this->mimePart($data, $type);
            }
            return $content;
        };
        $parts = (array) $parts;
        foreach ($parts as $content) {
            $message->addPart($part($content));
        }

        return $message;
    }

To

    public function mimeMessage($parts = array())
    {
        $message = new Mime\Message;
        $part = $this->mimeMessagePart($content);
        $parts = (array) $parts;
        foreach ($parts as $content) {
            $message->addPart($part($content));
        }

        return $message;
    }

function mimeMessagePart($content)
        {
            if (is_string($content)) {
                $content = new Mime\Part($content);
            }
            if (is_array($content)) {
                list($data, $type) = $content;
                $content = $this->mimePart($data, $type);
            }
            return $content;
        };

And it worked for me

from pi.

taiwen avatar taiwen commented on July 24, 2024

See updates in commit 77448fe

from pi.

voltan avatar voltan commented on July 24, 2024

Let me time to check

from pi.

taiwen avatar taiwen commented on July 24, 2024

Ok, I am also going to do test with my linode stack.

from pi.

Marc-pi avatar Marc-pi commented on July 24, 2024

hello,
about See var/config/service.mail.php
what is default value? phpmail?
there is no mail method setting anymore, can you explain how it works now?

from pi.

taiwen avatar taiwen commented on July 24, 2024

Default transport is sendmail through PHP mail function.
sendmail settings are configured in php.ini
Options for other transports can be set in service.mail.php, but only options defined by Zend/Mail are accepted.

from pi.

voltan avatar voltan commented on July 24, 2024

I test it, on server send mail system work will and without problem, Just it have problem in submitted mail, mail body set as text file and attached to the email, ( I send an example mail for you )

        // Set subject and body
        $subject = sprintf(__('Contact to %s , Subject : %s'), $values['department_title'], $values['subject']);
        $body = $values['message'];
        // Set message
        $message = Pi::service('mail')->message($subject, $body, 'text/html');
        $message->addTo($values['department_email'], $values['department_title']);
        $message->setEncoding("UTF-8");
        // Send mail
        $transport = Pi::service('mail')->transport();
        $transport->send($message);

I test whit template too, it use template very will , but again send body as attach file and I don't know how I can set information on template

from pi.

taiwen avatar taiwen commented on July 24, 2024

Mail service improved in commit 45d7947
BTW, I can not reproduce the attachment issue.

from pi.

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.