Git Product home page Git Product logo

Comments (5)

lmakarov avatar lmakarov commented on July 23, 2024

Thanks for reporting. This was indeed fixed at some point in #117, but then re-introduced in #163 and missed in the review process.

from service-cli.

lmakarov avatar lmakarov commented on July 23, 2024

Hmm... I guess I was too quick to judge the situation here.

#117 resulted in #142, which lead to that change being reverted back in #149.

Verdict: To use the plain PHP mail() function with MailHog, you have to set --read-envelope-from in additional options:

$result = mail($to, $subject, $message, $headers, '--read-envelope-from');

I'm going to mention this in the MailHog integration docs.

from service-cli.

mathias-heilmann avatar mathias-heilmann commented on July 23, 2024

Sorry, but this is not working for me. I tried it with the 5th parameter --read-envelope-from for the mail function, only -f [email protected] does it. Did a fin update before.

I am looking for a variant, which I may can put in the .docksal/etc/php/php.ini

It finally worked with sendmail_path = '/usr/bin/msmtp -t --host=mail --port=1025 -f [email protected]' in the php.ini

from service-cli.

lmakarov avatar lmakarov commented on July 23, 2024

IDK... Here's the script I'm using for testing:

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = array(
  'From' => '[email protected]',  // This one can be dropped if setting`-f [email protected]`
  // The rest are optional
  // 'Reply-To' => '[email protected]',
  // 'X-Mailer' => 'PHP/' . phpversion(),
  // 'Return-Path' => '[email protected]',
);
$result = mail($to, $subject, $message, $headers);
// $result = mail($to, $subject, $message, $headers, '--read-envelope-from');
// $result = mail($to, $subject, $message, $headers, '-f [email protected]');

var_dump($result);

Using docksal/cli:php7.4-3.0 image and various combinations of the 5th arg in mail() vs sendmail_path in .docksal/etc/php/php.ini:

; Mail settings
sendmail_path = '/usr/bin/msmtp -t --host=mail --port=1025'
; sendmail_path = '/usr/bin/msmtp -t --host=mail --port=1025 --read-envelope-from'
; sendmail_path = '/usr/bin/msmtp -t --host=mail --port=1025 -f [email protected]'

It only fails when:

  • there are no options on either side
  • there is --read-envelope-from on one side and -f [email protected] on the other side

All other combinations work just fine for me.

from service-cli.

lmakarov avatar lmakarov commented on July 23, 2024

After giving this more thought, I'm leaning towards setting a default value for --from/-f in php.ini in this image.

Something like:

sendmail_path = '/usr/bin/msmtp -t --host=mail --port=1025 --from=docker@cli'

This configuration will allow using PHP's built-in mail() without extra arguments and it also does not cause issues with Drupal/etc.

from service-cli.

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.