Contao > 4.3 sending emails with sendmail throw error on some providers - symfony

Older Versions of Contao (till 4.3) working like expected with sending emails via sendmail.
After upgrade to Contao 4.9 I got some errors at Providers like 1u1 / ionos or mittwald.
The error in the logs sound like:
"Expected response code 220 but got an empty response"
Sending Mails from CLI of the Server (means if logged in via SSH) working like expected:sendmail test" |
/usr/sbin/sendmail -t -v -f sender#domain.com reciepient#otherOne.com

The solution is to add this to config/config.yml
swiftmailer:
default_mailer: default
mailers:
default:
url: '%env(MAILER_URL)%'
transport: sendmail
command: '/usr/sbin/sendmail -t -i'
After that, clear the Contao-Cache (e.g. via contao-manager.phar) and give it a try.
The reason for that issue is, that by default the swiftMailer use sendmail -bs as command, which means that sendmail run as standalone Service.
Depending at the way your provider configure it's sendmail, this will be the cause of the error.

If you update symfony/swiftmailer-bundle to version 3.5.0, then the default value used for the sendmail command will be read from the PHP configuration. See https://github.com/symfony/swiftmailer-bundle/pull/302
So provided the PHP configuration of your hosting environment contains the correct command in sendmail_path, sending emails should work without any changes.

Related

Euca 5.0 Ansible Console Task Failing

Background:
I am only able to get past the ansible console install/config tasks by adding --region localhost to anywhere in: /usr/share/eucalyptus-ansible/roles/cloud-post/tasks/console.yml wherever it calls tools that take that argument.
Otherwise each sub task fails like this: ["euca-describe-images: error: connection error (('Connection aborted.', gaierror(-2, 'Name or service not known')))"]
Running the commands from that playbook directly on the euca server being configured gives the same result unless I specify --region localhost
Problem:
I'm stuck here: [cloud-post : update console route53 system domain for eucalyptus-cloud authentication]
Error: "euform-update-stack: error (ValidationError): No updates are to be performed.", "stderr_lines": ["euform-update-stack: error (ValidationError): No updates are to be performed."]
All services are running except the ImagingBackend is Not Ready
No instances are running according to euca-describe-instances
Images are available:
IMAGE ami-5be483c81cf8bd65c eucalyptus-console-image-5-0-823/eucalyptus-console-image-5-0-823.raw.manifest.xml 000216594841 available private x86_64 machine instance-store hvm
TAG image ami-5be483c81cf8bd65c type eucalyptus-console-image
TAG image ami-5be483c81cf8bd65c version 5.0.823
IMAGE ami-f31092ddb73e29af9 eucalyptus-service-image-v5.0.100/eucalyptus-service-image.raw.manifest.xml 000216594841 available privatx86_64 machine instance-store hvm
TAG image ami-f31092ddb73e29af9 provides imaging,loadbalancing
TAG image ami-f31092ddb73e29af9 type eucalyptus-service-image
TAG image ami-f31092ddb73e29af9 version 5.0.100
---
all:
hosts:
exp-euca.lan.com:
exp-enc-[01:02].lan.com:
vars:
vpcmido_public_ip_range: "192.168.100.5-192.168.100.254"
vpcmido_public_ip_cidr: "192.168.100.1/24"
cloud_system_dns_dnsdomain: "cloud.lan.com"
cloud_public_port: 443
eucalyptus_console_cloud_deploy: yes
cloud_service_image_rpm: no
cloud_properties:
services.imaging.worker.ntp_server: "x.x.x.x"
services.loadbalancing.worker.ntp_server: "x.x.x.x"
children:
cloud:
hosts:
exp-euca.lan.com:
console:
hosts:
exp-euca.lan.com:
node:
hosts:
exp-enc-[01:02].lan.com:
EDIT:
Solved. Details are in the comments of the marked answer.
The name error most likely means that DNS for the domain cloud.lan.com is not being correctly delegated to your deployment. To test this, check if the nameserver is found:
dig +short NS cloud.lan.com
you should see "ns1.cloud.lan.com" and then should be able to use that nameserver to resolve services, e.g.
dig +short ec2.cloud.lan.com #ns1.cloud.lan.com
which should be the IP of the host for the compute service.
The second item is a bug in the ansible playbook that occurs when the stack is already present and up to date. To work around it, you can either update your playbook or delete the stack before running the playbook. Depending on how far the playbook progressed you may have a script to do this:
/usr/local/bin/console-manage-stack -a delete
the related playbook change is https://github.com/AppScale/ats-deploy/pull/36

Forbidden when trying to register-user on axon server 4.4

After succesfully installing local axon-server-se version 4.4 I am not able to register users. I am getting 403 back from axon-server (forbidden). Users command, which should list all users on axon-server, returns empty result.
Register a user:
java -jar axonserver-cli.jar register-user -S https://AXON_SERVER:8024 -t TOKEN -u admin -p test -r ADMIN
results in
Error processing command 'register-user' on 'https://AXON_SERVER:8024/v1/users': HTTP/1.1 403 - {"timestamp":1599137927417,"status":403,"error":"Forbidden","message":"Forbidden","path":"/v1/users"}
This is a known issue for Axon and it is already fixed on 4.4.1 version, which was released yesterday!
As of version 4.4.1, you have a new properties for this case: axoniq.axonserver.accesscontrol.adminToken. This property should get the token you want to use on CLI as Admin.
If you have to stick to 4.4 though, the workaround is to create the very first admin user with access control disabled and enable it afterwards.

MailDev with Symfony 5 Mailer TLS crash

I'm working on my local machine on a Symfony 5 project. To test some mail functionality, I decided to use Node.js MailDev package.
The problem is that I found that MailDev does not support TLS encryption at this moment (version 1.1.0), and I found nothing on Symfony Mailer configuration that's allowed me to disable mail encryption.
When I try to send an email with encryption, MailDev server just crashes.
How can I solve that?
Thanks,
Navalex
Please try:
In .env file: MAILER_DSN=smtp://localhost:1025
Start server: maildev --hide-extensions STARTTLS
if you are using docker try this command
docker run -p 1080:80 -p 1025:25 nameofyourcontainer --web 80 --smtp 25 --hide-extensions STARTTLS

Swiftmail doesn't send mail but no error, symfony on docker container

I'm working on a symfony project on docker container and i set up a Mailer service which use swiftmailer and notfloran/mjml-bundle to send mail.
the mjml bndle needs mjml binary which i installed on the container with npm install mjml.
In the code :
$mail = new \Swift_Message();
$mail
->setFrom($from)
->setTo($to)
->setSubject($subject)
->setBody($body)
->setContentType('text/mjml');
$this->mailer->send($mail);
The thing is that when i request the function which send the mail via the docker container, there is no error but it does not send the mail.
But when i start a server with php -S adress -t public and i request the function which send the mail, the mail is sent.
EDIT: i tried to log the processus. In the log there is a mjml binary not found but when i enter in the container the mjml command works
SwiftMailer is kinda hard to debug in that situation. I had a similiar one.
If you're using docker then you have to make sure that an email client is setup and configured so that php can use it.
I'm using php:7.4-fpm and adding msmtp through my own dockerfile
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y msmtp
# msmtp - mailer
COPY build/etc/msmtprc /etc/msmtprc
RUN chmod 600 /etc/msmtprc
msmtprc file:
account default
host mailhost.mobilcom.de
port 25
auth off
user null
password null
from "docker#klarmobil.de"
logfile /var/log/msmtp.log
And add to php.ini:
sendmail_path = /usr/bin/msmtp -t
Then try again to send you mail

Configure Symfony2/Swiftmailer to use "sendmail -t"

I'm currently trying to get Symfony2/Swiftmailer to send the contents of a submitted form via mail. My parameters.yml contains the following:
mailer_transport: sendmail
mailer_host: ~
mailer_user: ~
mailer_password: ~
Since the sendmail version on my server does not support the -bs option, which Swiftmailer seems to use by default, I have to find a way to tell Symfony2/Swiftmailer to use sendmail -t instead. Swift_Transport_SendmailTransport seems to support that, but there doesn't seem to be a corresponding configuration option for SwiftmailerBundle.
How do I tell Swiftmailer to use sendmail -t (preferrably via configuration)?
Edit 2: For now, I'm using
$message = \Swift_Message::newInstance()
[…];
$transport = $this->get('swiftmailer.mailer.default.transport.real');
if ($transport instanceof \Swift_Transport_SendmailTransport) {
$transport->setCommand('/usr/sbin/sendmail -t');
}
$this->get('mailer')->send($message);
I'm still wondering if there's a better way to do this, though.
Just spent the day on this very issue.
I prefer using straight configuration for this kind of thing, and I found this to work:
# app/config/services.yml
services:
swiftmailer.mailer.default.transport:
class: Swift_SendmailTransport
arguments: ['/usr/sbin/sendmail -t']
This configuration should work.
mailer_transport: sendmail
mailer_host: /usr/bin/sendmail # wherever your mail is
#mailer_user: ~
#mailer_password: ~
If there is still problem,
A. check who are sending mail to someone#wxy.com
1. console - check your permission to access sendmail
2. web - check web user like wwww-data can access sendmail
B. check your mail log /var/log/maillog
When Symfony Swiftmailer send,
1. mail log has not been processed, then PHP side problem.
2. else if: send to outlook
it is TLS handshake problem, it might be from outlook tls handshake.
FYI, sendmail TLS is not working with outlook well.
add next line to /etc/mail/access
Try_TLS:wxy.com NO
3. else:
Sorry, google with mail log error messages again .
I was looking for the same thing as you and i found that there is now a SendMailTransport class.
Here is the documentation : http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport

Resources