Giter Site home page Giter Site logo

goaliomailservice's Introduction

GoalioMailService

Version 1.2.0 Created by the goalio UG (haftungsbeschränkt)

Introduction

Provide configurable Mail Transport Factory and simple messaging for ZF2

Requirements

Features / Goals

  • Configure transport service for using Zend\Mail [COMPLETE]

Changelog

With ZF2.3 the Transport Factory changed. This made changes to the configuration in the goaliomailservice.global.php (and goaliomailservice.local.php) neccessary. I tried to check this in my own factory, but please be aware of this.

Installation

Main Setup

With composer

  1. Add this project and the requirements in your composer.json:

    "require": {
        "goalio/goalio-mailservice": "1.*"
    }
  2. Now tell composer to download GoalioMailService by running the command:

    $ php composer.phar update

Post installation

  1. Enabling it in your application.config.phpfile.

    <?php
    return array(
        'modules' => array(
            // ...
            'GoalioMailService'
        ),
        // ...
    );
  2. Copy the configuration files for local and global from ./vendor/goalio/goalio-mailservice/config/goaliomailservice.{local,global}.php.dist to ./config/autoload/goaliomailservice.{local,global}.php and change the values as desired.

  3. If you are using the FileTransport (for development) create the directory ./data/mail.

Usage

// The template used by the PhpRenderer to create the content of the mail
$viewTemplate = 'module/email/testmail';

// The ViewModel variables to pass into the renderer
$value = array('foo' => 'bar');

$mailService = $this->getServiceManager()->get('goaliomailservice_message');
$message = $mailService->createTextMessage($from, $to, $subject, $viewTemplate, $values);
$mailService->send($message);

SMTP Setup

GoalioMailService uses sendmail by default, but you can set it up to use SMTP by putting your information in the config file like this:

$settings = array(
    'type' => 'Zend\Mail\Transport\Smtp',

    'options_class' => 'Zend\Mail\Transport\SmtpOptions',

    'options' => array(
        'host' => 'smtp.gmail.com',
        'connection_class' => 'login',
        'connection_config' => array(
            'ssl' => 'tls',
            'username' => '[email protected]',
            'password' => 'YOUR-PASSWORD-HERE'
        ),
        'port' => 587
    )
);

goaliomailservice's People

Contributors

anduk avatar claytondaley avatar dorongutman avatar pdobrigkeit avatar personman avatar stefanorg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

goaliomailservice's Issues

Mail is going to spam

Dude this library is sending the emails in spam. Find the code below -

$mailService = $this->getServiceLocator()->get('goaliomailservice_message');
$content = new MimeMessage();
$htmlPart = new MimePart("Please find attached this report received from a " . $clientName . " user.

Regards,
" . $this->zfcUserAuthentication()->getIdentity()->getDisplayName() . "



");
$htmlPart->type = 'text/html';
$textPart = new MimePart("Please find attached this report received from a " . $clientName . " user.

            Regards,
            " . $this->zfcUserAuthentication()->getIdentity()->getDisplayName());
    $textPart->type = 'text/plain';
    $content->setParts(array($textPart, $htmlPart));

    $contentPart = new MimePart($content->generateMessage());
    $contentPart->type = 'multipart/alternative;' . PHP_EOL . ' boundary="' . $content->getMime()->boundary() . '"';

    $attachment = new MimePart(fopen($pdfPath, 'r'));
    $attachment->type = 'application/pdf';
    $attachment->filename = 'report' . time() . '.pdf';
    $attachment->encoding = Mime::ENCODING_BASE64;
    $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;

    $body = new MimeMessage();
    $body->setParts(array($contentPart, $attachment));

    $message = new Message();
    $message->setEncoding('utf-8')
            ->addTo($email)
            ->addFrom(array($this->getLoggedInUserAdminFromEmail() => $this->getLoggedInUserAdminContactName()))
            ->setSubject($this->getLoggedInUserAdminContactName().' Report')
            ->setBody($body);
    try {
        $mailService->send($message);
    } catch (\Exception $e) {
        
    }

mail_snapshot

Message created with createHtmlMessage is rendered as plain text in the e-mail clients

Hello,

Thanks for the nice package!

When I create a new e-mail message with the createHtmlMessage method the whole HTML content is displayed as plain text in Gmail, Yahoo and other e-mail clients.

It seems that the body of the multipart e-mail message is not constructed correctly. There are two Zend Framework 2 issues, which seem to be related to the problem:

zendframework/zendframework#2460
zendframework/zendframework#5708

As far as I can see here:
http://akrabat.com/zend-framework-2/sending-attachments-in-multipart-emails-with-zendmail/
the encoding of the message parts is Mime::ENCODING_QUOTEDPRINTABLE and the content type of the whole multipart message is changed according to that if it contains attachments or not:
$message->getHeaders()->get('content-type')->setType($messageType);
because it is multipart/mixed by default in Zend Framework.

Could we expect a fix for the HTML messages soon?

Thanks!

zendframework 2.4 compatibility

Today, when updating zendframework to2.4, dependencies say that your module requires zendframework 2.3.*.

Requirementes listed on your page lists Zend Framework 2 (> 2.3.3). Could you please update your composer with matching requirements? In this way we could update to 2.4 easily.

Let me know if you expect a pull request for this.

Readme Edit - change options key to transport_options

Could you change this
$settings = array(
'transport_class' => 'Zend\Mail\Transport\Smtp',

'options_class' => 'Zend\Mail\Transport\SmtpOptions',

'options' => array(
    'host' => 'smtp.gmail.com',
    'connection_class' => 'login',
    'connection_config' => array(
        'ssl' => 'tls',
        'username' => '[email protected]',
        'password' => 'YOUR-PASSWORD-HERE'
    ),
    'port' => 587
)

);
to
$settings = array(
'transport_class' => 'Zend\Mail\Transport\Smtp',

'options_class' => 'Zend\Mail\Transport\SmtpOptions',

'transport_options' => array(
    'host' => 'smtp.gmail.com',
    'connection_class' => 'login',
    'connection_config' => array(
        'ssl' => 'tls',
        'username' => '[email protected]',
        'password' => 'YOUR-PASSWORD-HERE'
    ),
    'port' => 587
)

);
The first one is misleading and leads to a Zend\ServiceManager\Exception\ServiceNotCreatedException when requesting for password reset. With the edit, everything goes fine.

latest version is no longer compatible with ZF 2.2

latest version does not retain backwards compatibility with ZF 2.2 because of composer.json definitions in this lib

PHP Fatal error: Class 'Zend\Mail\Transport\Factory' not found in ...../vendor/goalio/goalio-mailservice/src/GoalioMailService/Mail/Transport/Service/TransportFactory.php on line 14,

Zend\Mail\Transport\Factory is a new file as of ZF 2.3

setting the version of GoalioMailService in our projects composer.json explicitly to 1.0.1 rather than 1.* either before or after "goalio/goalio-forgotpassword" : "1.0.2", does not resolve the issue

SMTP setup instructions

I've got your module working with SMTP and I'd like to add some instructions so others can do the same. Should I just put them in the readme file or have a commented-out section in the config file?

Thanks for a very useful module!

fhdfh

xfgtjzgfheRFhrdzfhrfheheth

End of line characters

screenshot from 2013-07-10 09 49 49
If I construct a view template and omit CRLF at the end of each line, some mail systems reject the email and will not send it. If I add CRLF to the end of every line, this satisfies the complaining mail systems, but other systems (like gmail) show the CRLF characters in the email. I am sending using SMTP.
Am I doing it wrong?

I have added a screenshot of the error I am getting. This code works if I send from my local machine using gmail, but fails if I try to send from the live server which I believe is using Qmail on Centos. Qmail complains about bare linefeeds whereas gmail seems more tolerant.

instance for goaliomailservice_message fails.

After you enable the plugin, and make the necessary changes in the database / application settings and add the conf. to the autoload, when trying to use the module it fails with:

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for goaliomailservice_message

zf3 support

Can new version be tagged to support zf3?

Problem with accents in text plain mail

When creating mail messages that use common accents (e.g. áéíóú), it is not displayed correctly on common email clients. This is because the mail message isn't mime encoded. Header is displayed well, though.

Adding mime encoding for plain text messages should correct this issue.

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (GoalioMailService) could not be initialized.

I try to install GoalioMailservice without success

here the error when i open my website
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (GoalioMailService) could not be initialized.' in /var/www/myproject/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 195

Zend\ModuleManager\Exception\RuntimeException: Module (GoalioMailService) could not be initialized. in /var/www/myproject/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 195

I follow the readme file and i follow the step but without success.
I have zfc-user 1.2.3 on my sistem.

configuration file are incorrect

with the new version using class \Zend\Mail\Transport\Factory to create the transport class, you need to change the configuration file from this:

    'transport_class' => 'Zend\Mail\Transport\File',

    'options_class' => 'Zend\Mail\Transport\FileOptions',

    'transport_options' => array(
        'path'              => 'data/mail/',
    ),

to this

    'type' => 'file',
    'options' => [
        'path' => 'data/mail'
    ],

this isn't still backward compatible with zf 2.2 like noticed in issue #18

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.