Giter Site home page Giter Site logo

Comments (3)

pdobrigkeit avatar pdobrigkeit commented on August 28, 2024

Hey,

as there are also a couple issues open with the ZF update from 2.2 to 2.3 I guess I will take some time this week to fix the open stuff.

It would be quite helpful if you could post a little code so I can test sending HTML mails?

from goaliomailservice.

pdrosos avatar pdrosos commented on August 28, 2024

Hi,

The code I use for creating and sending an HTML message is simple:

$mailService = $this->getServiceManager()->get('goaliomailservice_message');
$message = $mailService->createHtmlMessage(
    $from,
    $to,
    $subject,
    $emailTemplate,
    array(
        'data' => $data
    )
);
$mailService->send($message);

and the sent e-mail is rendered as plain text in the e-mail clients. I have tried to add this line just before sending the e-mail:

$message->getHeaders()->get('content-type')->setType('multipart/alternative');

which is mentioned as workaround in the above ZF2 issues, but it didn't help. The email is rendered as attachment with name "noname" in the clients and this attachment is empty.

from goaliomailservice.

pdrosos avatar pdrosos commented on August 28, 2024

Hi again,

When I create multipart e-mail with only one HTML part, the e-mail is rendered properly. Here is the code:

$mailService = $this->getServiceManager()->get('goaliomailservice_message');
$html = $mailService->getRenderer()->render(
    $emailTemplate,
    array(
        'data' => $data
    )
);

$htmlPart = new MimePart($html);
$htmlPart->type = "text/html; charset=UTF-8";
$htmlPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;

$body = new MimeMessage();
$body->setParts(array($htmlPart));

$message = new Message();
$message->setFrom($from, $fromName)
    ->setEncoding('utf-8')
    ->setSubject($subject)
    ->setBody($body)
    ->setTo($to);

$mailService->send($message);

Hope this helps and I it will be really great if the module is fixed soon and multipart messages are rendered properly.

from goaliomailservice.

Related Issues (16)

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.