SMTP without IMAP

Infos:

  • Used Zammad version: 6.4.1-1739486678.57fe79e0.noble
  • Used Zammad installation type: APT
  • Operating system: Ubuntu 24.04
  • Browser + version: Chromium 117.0.5938.132

Expected behavior:

  • I would like to use O365 for inbound mail with multiple mailboxes and SMTP for all outbound email. We point all internal servers at a local mail relay (postfix) that sends everything out through AWS SES. There are no credentials required for the relay since IP filtering is used and all other SMTP traffic is blocked.
    I believe this is similar to these issues, but not close enough to be answered already:
    Single SMTP config for all outbound emails
    Diffrent server for smtp and imap

Actual behavior:

  • Unable to find documentation on how to setup outbound email for all items through an SMTP only connector.
1 Like

After looking at this a bit more, I came across a similar issue on GitHub: Issue 3048 from a few years ago and also Dispatch messages with Sendmail — Zammad Admin Documentation documentation.

I modified the rails command a bit to the following and was able to create an email connector with null inbound and SMTP outbound.

zammad run rails r "Channel.create(area: 'Email::Account', options: { inbound: { adapter: 'null', options: {} }, outbound: { adapter: 'smtp' } }, active: true, preferences: { editable: true }, updated_by_id: 1, created_by_id: 1)"

I then go to edit the outbound mail connector to add my SMTP server address and port. When saving I get the following:

I then cancel the inbound page because I am not using this for inbound:

I now have the following error in the email page:

And this in the health page:

Channel: Email::Account out #<NoMethodError: undefined method `key?' for nil:NilClass>

I am also receiving emails from the “email notifications” connector under emails about the above not working. All settings are the same, so I feel this is likely a configuration issue on my outbound-only SMTP connector I created with the rails console.


Ticket (Test) has been updated by "-". 

Information: 
Unable to send email to 'email@example.com': Can't use Channel::Driver::Smtp: #<NoMethodError: undefined method `key?' for nil:NilClass>

production.log

I, [2025-02-24T23:37:22.798004#807-183580]  INFO -- : 2025-02-24T23:37:22+0000: [Worker(host:MyServer pid:807)] Job TicketArticleCommunicateEmailJob [5d66e7b5-5e30-4120->E, [2025-02-24T23:37:22.831990#807-183580] ERROR -- : Can't use Channel::Driver::Smtp: #<NoMethodError: undefined method `key?' for nil:NilClass>
E, [2025-02-24T23:37:22.832127#807-183580] ERROR -- : undefined method `key?' for nil:NilClass (NoMethodError)
app/models/channel/driver/smtp.rb:36:in `deliver'
app/models/channel.rb:266:in `deliver'
app/jobs/ticket_article_communicate_email_job.rb:56:in `perform'
lib/background_services/service/process_delayed_jobs.rb:25:in `block (2 levels) in launch'
lib/background_services/service/process_delayed_jobs.rb:23:in `block in launch'
lib/background_services/service/process_delayed_jobs.rb:20:in `loop'
lib/background_services/service/process_delayed_jobs.rb:20:in `launch'
lib/background_services/service.rb:27:in `block in run'
lib/application_handle_info.rb:19:in `use'
lib/background_services/service.rb:33:in `block in run_in_service_context'
lib/background_services/service.rb:32:in `run_in_service_context'
lib/background_services/service.rb:26:in `run'
lib/background_services.rb:71:in `block in start_as_thread'
E, [2025-02-24T23:37:22.916530#807-183580] ERROR -- : Can't use Channel::Driver::Smtp: #<NoMethodError: undefined method `key?' for nil:NilClass>
I, [2025-02-24T23:37:23.114261#807-183580]  INFO -- : Execute trigger (Ticket_Notification_Update/4) for this object (Ticket:789/Loop:1)

I’m really coming to the end of my troubleshooting ability here. I would really appreciate it if someone from the dev team could take a look at these errors and point me in the right direction or let me know if more logs/errors are needed.

I have tried to mirror the SMTP settings for the default notification channel but still receive the same error. Notification channel:

[26] pry(main)> Channel.find(1)
=> #<Channel:0x0000789ad26ad0c0
 id: 1,
 group_id: 1,
 area: "Email::Notification",
 options:
  {"outbound"=>
    {"adapter"=>"smtp",
     "options"=>
      {"host"=>"smtprelay.domain.com",
       "user"=>"",
       "password"=>"",
       "port"=>"25",
       "ssl_verify"=>true,
       "domain"=>"ticket.domain.com",
       "enable_starttls_auto"=>true}}},
 active: true,
 preferences: {"online_service_disable"=>true},
 last_log_in: nil,
 last_log_out: "",
 status_in: nil,
 status_out: "ok",

When I exclude the “inbound” option the email tab completely breaks and shows nothing. I have also check the /opt/zammad/app/models/channel/driver/smtp.rb file to see if I am adding extra fields to the options but that does not seem to be the case.

This is my current manually created email channel I am working with:

[19] pry(main)> channel
=> #<Channel:0x0000789ad2676188
 id: 6,
 group_id: nil,
 area: "Email::Account",
 options:
  {"inbound"=>{"adapter"=>"null", "options"=>{}},
   "outbound"=>
    {"adapter"=>"smtp",
     "host"=>"smtprelay.domain.com",
     "port"=>"25",
     "ssl_verify"=>true,
     "domain"=>"ticket.domain.com",
     "enable_starttls_auto"=>true}},
 active: true,
 preferences: {"editable"=>false},
 last_log_in: nil,
 last_log_out: "#<NoMethodError: undefined method `key?' for nil:NilClass>",
 status_in: nil,
 status_out: "error",

I was able to solve this through trial and error by manually creating an adapter with only the host, username and password specified. Will post the Ruby commands here later today or tomorrow when I have a chance.

Edit: Below is what worked.

Through all of my testing I tried adding additional options such as enforcing TLS but all caused breakage. The only options that seemed to work were host and port as seem below. Do not make this editable because any changes through the web console will make Zammad mad and not allow saving.

Channel.create(area: ‘Email::Account’, options: { inbound: { adapter: ‘null’, options: {} }, outbound: { adapter: ‘smtp’, options: { host: ‘smtprelay.example.com’, port: 25} } }, active: true, preferences: { editable: false }, updated_by_id: 1, created_by_id: 1)

We generally don’t suggest or recommend to fiddle a email account manually into Zammad via rails console. This skips verification steps that the guided UI process does.

If you provide commands, please use at least spoiler tags to visually help people understand that what they do is potentially “dangerous”.

I would disagree a bit about how dangerous this is since your own documentation has many instances of requiring the rails console access to make changes since many things are missing from the web UI. I can’t recall any of them that note the changes as dangerous. A perfect example is one of my starting points from your sendmail guide.

I will however make sure to use a spoiler as requested.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.