Channel.create Syntax changed?

I am using Zammad 6.3.1-1720156707.17f20fad.focal

did the syntax of Channel.create change? Our groups are all Api based, so all tickets are only created by API

and so far i created a channel using this syntax:

mychannel = Channel.create(
            area: 'Email::Account',
            options: {
                inbound: {
                    adapter: 'null',
                    options: {}
                },
                outbound: {
                    adapter: 'smtp' ,
                    options: {
                        host: "smtp.sendgrid.net",
                        user: "apikey",
                        password: "removed",
                        port: 465,
                        ssl: true,
                        domain: Setting.get('fqdn'),
                        enable_starttls_auto: true
                    }
                }
            },
            active: true,
            preferences: {
              editable: false
            },
            updated_by_id: 1,
            created_by_id: 1
)

somehow it doesnt work anymore, the return on console is:

=> #<Channel:0x00007f9a3c817a80
 id: nil,
 group_id: nil,
 area: "Email::Account",
 options:
  {"inbound"=>{"adapter"=>"null", "options"=>{}},
   "outbound"=>{"adapter"=>"smtp", "options"=>{"host"=>"smtp.sendgrid.net", "user"=>"apikey", "password"=>"removed", "port"=>465, "ssl"=>true, "domain"=>"ticket.removed.de", "enable_starttls_auto"=>true}}},
 active: true,
 preferences: {"editable"=>false},
 last_log_in: nil,
 last_log_out: nil,
 status_in: nil,
 status_out: nil,
 updated_by_id: 1,
 created_by_id: 1,
 created_at: nil,
 updated_at: nil>

what am i doing wrong? its not really an “error” message for some reason too? but still if i look into the data base no channel is added to the “channels” table

hm I’m not aware of changes but you could try to use create!( instead create( then maybe some exceptions show up?

ActiveRecord::RecordInvalid: Validation failed: The provided email account is already in use.
from /opt/zammad/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.4/lib/active_record/validations.rb:80:in `raise_validation_error’

thats weird, its the same progress i always use

as we are using api based groups i always create an “empty email” channel, then next step would be adding a mail to it with

`EmailAddress.create(`
`channel_id: mychannel.id,`
`name: Setting.get(` `'organization'` `),`
`email: ` `"some@mail.com"` `,`
`active: true,`
`updated_at: Time.now,`
`created_at: Time.now,`
`created_by_id: 1,`
`updated_by_id: 1`

`)`

i have about 15 groups now where this process worked fine

This validation you’re faced with is from April 5th, 2024.

Why are you setting inbound with the null adapter and empty options?

Because it’s a documented use case that I documented years ago with input from Martin (who also said it’s illegal this week :D)

https://admin-docs.zammad.org/en/latest/channels/email/advanced/sendmail.html

There are use cases where people want to use sendout only. Whatever the use case is.

Haha, ok. :smiley:

No idea right now, maybe the validation is not prepared for such a case.

the input is compelty via api call, we send our mails to sendgrid inbound parse - have an AI run over it to extract some part into zammad custom fields, and thus the actual ticket is added with an API call

is there any work around? does channel.create do more than just adding a row in the db channels table? then i could just inject it directly into the database

The ssl attribute no longer exists. There’s a new ssl_verify attribute which allows you to verify the SSL connection by using true. Talking about SMTP outgoing here.

No matter in what scenario. Do not -ever- take this as an option please. Don’t even waste time thinking about it.

Going around the application may break it if you’re ignoring code based data checks. Apart from caching and so on. It’s not worth it.

thanks,

Can you give me an updated example?

Do i have any work around so i can create a channel that does not fetch mail from anywhere for the time being?

No offense, but please use your code and replace stuff like I suggested. If things don’t work then, provide error messages.

ActiveRecord::RecordInvalid: Validation failed: The provided email account is already in use.
from /opt/zammad/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.4/lib/active_record/validations.rb:80:in `raise_validation_error’

the error message does not change

mychannel2 = Channel.create!(
            area: 'Email::Account',
            options: {
                inbound: {
                    adapter: 'null',
                    options: {}
                },
                outbound: {
                    adapter: 'smtp' ,
                    options: {
                        host: "smtp.sendgrid.net",
                        user: "apikey",
                        password: "removed",
                        port: 465,
                        ssl_verify: true,
                        domain: Setting.get('fqdn'),
                        enable_starttls_auto: true
                    }
                }
            },
            active: true,
            preferences: {
              editable: false
            },
            updated_by_id: 1,
            created_by_id: 1
)

Use each SMTP server with the user name once. Why would you not?

i am not sure what you mean, we only have one smtp server so its always the same outbound one - the whole zammad is using just one single outbound smtp

I still would be very happy with an instruction what to do to be able to create channels again

Please, do not bump threads. Our team members provide free community support when there is spare time in between. If you need faster responses, consider professional support services:
The Best Helpdesk at the Best Prices | Zammad

we are happy to fix this bug ourselves and put in a pull request if we get some confirmation that this is a bug and how this should be handled

Soluce found by fail and retry : do not precise adapter field for inbound.

zammad run rails r “Channel.create(area: ‘Email::Account’, options: { inbound: { options: {} }, outbound: { adapter: ‘sendmail’ } }, active: true, preferences: { editable: false }, updated_by_id: 1, created_by_id: 1)”