Closed ixlayer closed 3 years ago
Please paste your YAML snippet in a code block:
```
<paste code here>
```
I can't make any sense of the YAML without it
enabled: true
from: no-reply@example.com
from_name: no-reply
to:
- test@example.com
- test1@example.com
to_name: test
mailer:
engine: smtp
smtp:
server: smtp.gmail.com
port: 587
encryption: tls
user: no-reply@example.com
password: password
sendmail:
bin: /usr/sbin/sendmail
content_type: text/html
debug: true
email:
from: '{{ config.plugins.email.from }}'
to: ['{{ config.plugins.email.to }}', '{{ form.value.email }}']
subject: '[Test] {{ form.value.name|e }}'
body: '{% include ''forms/data.html.twig'' %}'
ok thanks, i'll take a look
Works fine for me, i get two emails when i send via mailtrap.io, one to each address.
Not works for me :( single:
[2017-11-01 00:47:51] email.DEBUG: ++ Starting Swift_SmtpTransport << 220 mailtrap.io ESMTP ready >> EHLO myhost.ru << 250-mailtrap.io 250-SIZE 5242880 250-PIPELINING 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250-AUTH PLAIN LOGIN CRAM-MD5 250 STARTTLS >> AUTH CRAM-MD5 << 334 PDIwMzEyMDE1NzcuMTUwOTQ4NjQ3NEBtYWlsdHJhcC5pbz4= >> YTMyMjI1MDY3YTM1NTggZTM4MzE2YTk3MzM1M2YyNGEyOTU3OGU5ODk3NDJiMDk= << 235 2.0.0 OK ++ Swift_SmtpTransport started >> MAIL FROM:<ineon@mail.ru> << 250 2.1.0 Ok >> RCPT TO:<ixlayer@gmail.com> << 250 2.1.0 Ok >> DATA << 354 Go ahead >> . << 250 2.0.0 Ok: queued [] []
multiple:
[2017-11-01 00:48:33] email.DEBUG: ++ Starting Swift_SmtpTransport << 220 mailtrap.io ESMTP ready >> EHLO myhost.ru << 250-mailtrap.io 250-SIZE 5242880 250-PIPELINING 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250-AUTH PLAIN LOGIN CRAM-MD5 250 STARTTLS >> AUTH CRAM-MD5 << 334 PDE3MDI0Mzk3MTguMTUwOTQ4NjUxOEBtYWlsdHJhcC5pbz4= >> YTMyMjI1MDY3YTM1NTggYWVkNGYyYjhkMzkyNjEyN2Q0NWYwMTE3NmY3ZDNlNzk= << 235 2.0.0 OK ++ Swift_SmtpTransport started [] []
Try putting in some manual email addresses rather than from the form (for testing).
I see the problem, your value for config.plugins.email.to
is already an array, so your actually creating an array with another array and a string, hence the error. Let me investigate.
direct writed address does not work too
email:
from: '{{ config.plugins.email.from }}'
to: 'test@example.com,test@example.com'
email:
from: '{{ config.plugins.email.from }}'
to: ['test@example.com', 'test@example.com']
works, but i can't get that output to be generated by Twig when there's an array for part of it. If you had only one to
in your email config it would work:
user/config/plugins/email.yaml
to: noreply@foo.com
Ok, i have a crappy way, but it works:
to: ['{{ config.plugins.email.to[0] }}', '{{ config.plugins.email.to[1] }}', '{{ form.value.email }}']
This builds the array manually, so if you ever add another email address in the email config, you would have to update the form to include it.
Hello! Only
to: [test@example.com, test1@example.com]
works for me, not
to: ['{{ config.plugins.email.to[0] }}', '{{ config.plugins.email.to[1] }}']
maybe config.plugins.email.to is not array?
It's not intended to be an array, but i was trying to get it working as one.
I've just run into the same issue, and used the same fix as @rhukster suggested above. Is there a more permanent fix available? Thanks
The ultimate issue was the author was trying to set an array with another array and a string. Ultimately this has to be output in YAML array format, which is really a string with square brackets. There are other ways to output this. an automated one could be:
to: ["{{ array(config.plugins.to)|merge([form.value.to])| join('","') | raw }}"]
This is will merge the config.plugins.to
array with a newly created array with form.value.to
in it, then join any array items resulting with ","
. Not tested but should work...
Thanks @rhukster - will check that out. Much appreciated
I guess this can be closed now.
Cannot sent email, when e-mail is set to multiple. Config: enabled: true from: no-reply@example.com from_name: no-reply to: