aimeos / aimeos-laravel

Laravel ecommerce package for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org/Laravel
MIT License
7.09k stars 1.04k forks source link

[2018.04] Mails not delivered under homestead/vagrant, yet laravel does send mails #238

Closed Quix0r closed 5 years ago

Quix0r commented 6 years ago

I have setup aimeos-shop under homestead and have it successfully running on nginx, yet no mail is being sent, except the default Laravel pages, like "reset password" and so.

I have this error message in logfile: Error while trying to send payment e-mail for order ID "1" and status "4": Cannot send message without a sender address

My .env file:

APP_NAME=Aimeos-Shop
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxx
APP_DEBUG=true
APP_URL=https://aimeos-shop.local

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=aimeos_shop
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=sendmail
MAIL_HOST=127.0.0.1
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@aimeos-shop.local
MAIL_FROM_NAME="Shop"

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

And I changed one setting in config/mail.php: 'sendmail' => '/usr/sbin/sendmail -t',

So this means the above mail settings work (Laravel's default reset-password feature sends out mail) but Aimeos seem to ignore it.

I also find it strange that this message pops up as it comes from AbstractSmtpTransport but I was never using it (tried mail as MAIL_DRIVER before).

Quix0r commented 6 years ago

And I have setup all 3 cron jobs.

aimeos commented 6 years ago

The sender name/email isn't used from the .env file in your version. That will be the case in the next one released in the next days but up to now, you have to add these lines in your ./config/shop file yourself: https://github.com/aimeos/aimeos-laravel/blob/master/src/config/shop.php#L52

For sending e-mails, Aimeos uses the SwiftMailer instance provided by Laravel: app( 'mailer' )->getSwiftMailer()

Quix0r commented 6 years ago

Thank you. I have changed it now. I'm testing it now.

I also had to set client->html->common->content->baseurl to env('APP_URL') to have it respect the setting from .env. Maybe worth changing the shop.php file?

Quix0r commented 6 years ago

I have the following "wrapper" scripts (Mittwald accepts parameter lists until 96 characters):

minutely.sh:

#!/bin/sh

./artisan $@ aimeos:jobs "order/export/csv order/email/delivery order/email/payment order/service/delivery subscription/export/csv customer/email/account" || exit 255

hourly.sh:

#!/bin/sh

./artisan $@ aimeos:jobs "customer/email/watch order/cleanup/unfinished order/service/async order/service/payment" || exit 255

daily.sh:

#!/bin/sh

./artisan $@ aimeos:jobs "admin/cache admin/log order/cleanup/unpaid product/bought index/rebuild index/optimize product/export/sitemap subscription/process/begin subscription/process/renew subscription/process/end" || exit 255

# @TODO Defect jobs:
./artisan $@ aimeos:jobs "catalog/import/csv product/import/csv"

The last one imports the whole .env file as products. Maybe another bug that needs tracking in other ticket. However, still no mail goes out. Under which circumstances when will mails be sent? When I order some items, I guess?

Quix0r commented 6 years ago

Ah, pcntl functions are disabled in FPM:

disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,

Which totally makes sense on web servers. But for CLI (cron), nothing is disabled. So how is your system working? Is a job only inserted by web part and the CLI (cron) in background will work on it? Then it should work, but still no mails.

Edit: I have done a testing order on my homestead/vagrant box.

aimeos commented 6 years ago

Do you get the e-mails now after you've removed the importer from the artisan aimeos:jobs command?

Quix0r commented 6 years ago

Yes, still no mail goes out.

aimeos commented 6 years ago

client/html/content/baseurl is now automatically set to Laravel's "app.url" and the new 2018.07 release is out now.

We've also tested sending e-mails to Mailtrap (only added username/password to .env file) and it worked as expected when executing ./artisan aimeos:jobs order/email/payment. All errors will be logged in the madmin_log table if there are any. E-mails will only be sent if the mshop_order_status table doesn't already contain an entry "email-payment" for that order.

Quix0r commented 6 years ago

Thank you, will test it when time permits.

Quix0r commented 6 years ago

Jupp, when permits. Please show patience ... Currently (I'm home now) my employer has an other more pressing project for me.

OT: Are you based in Germany? Is it possible to buy "premium" or business support? Maybe I can convince them.

aimeos commented 6 years ago

You can buy business support from the Aimeos company (based in Hamburg): https://aimeos.com/support/

aimeos commented 5 years ago

2018.4 is long gone and unsupported since the release of 2018.10 LTS. We close this isse now :)

Quix0r commented 5 years ago

My job with the company evaluating this software is canceled so I (I don't use it for my personal projects) cannot help here anymore. RIP ticket. ;-)