Bug 41026 - sendbasket or sendshelf need email validation
Summary: sendbasket or sendshelf need email validation
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-15 14:35 UTC by Marcel de Rooy
Modified: 2025-10-17 07:32 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2025-10-15 14:35:26 UTC
If you use that, it will be accepted. The line is parsed correctly by Email::Address. But exim will return a SMTP error.
Comment 1 Marcel de Rooy 2025-10-16 13:33:28 UTC
Note that adding two email addresses separated by a comma, does work and results in an email to two recipients.
The list of emails is in the to_address of the message queue.
Comment 2 Marcel de Rooy 2025-10-16 13:34:42 UTC
(In reply to Marcel de Rooy from comment #1)
> Note that adding two email addresses separated by a comma, does work and
> results in an email to two recipients.
> The list of emails is in the to_address of the message queue.

Another thing is if we really want that. This allows a logged-in patron to send a mail to a lot of recipients.
Comment 3 Marcel de Rooy 2025-10-16 14:25:30 UTC
(In reply to Marcel de Rooy from comment #0)
> If you use that, it will be accepted. The line is parsed correctly by
> Email::Address. But exim will return a SMTP error.

Changed the title.
But I meant here (in short) sending an address "Marcel <my@email.com>" will pass all current validation. But results in SMTP error.

Note that we pass the input param email just through to EnqueueLetter. Later on Koha::Email checks is_valid when processing the queue. But that algorithm is unreliable (bug 41025).
Comment 4 David Cook 2025-10-16 22:33:09 UTC
(In reply to Marcel de Rooy from comment #2)
> Another thing is if we really want that. This allows a logged-in patron to
> send a mail to a lot of recipients.

That's a very good point. This one might be a bit of a bug/feature. I know we've been expanding the number of places in Koha that allow multiple recipients, but that's not great when it's the OPAC I think...
Comment 5 David Cook 2025-10-16 22:34:06 UTC
(In reply to Marcel de Rooy from comment #0)
> If you use that, it will be accepted. The line is parsed correctly by
> Email::Address. But exim will return a SMTP error.

I'm not sure it's Koha's job to figure out if the email address is real? I think it's OK to get the SMTP error? For me, I think the key concern is "is this in email address format where the SMTP software can deal with it?"
Comment 6 Marcel de Rooy 2025-10-17 07:32:28 UTC
(In reply to David Cook from comment #5)
> (In reply to Marcel de Rooy from comment #0)
> > If you use that, it will be accepted. The line is parsed correctly by
> > Email::Address. But exim will return a SMTP error.
> 
> I'm not sure it's Koha's job to figure out if the email address is real? I
> think it's OK to get the SMTP error? For me, I think the key concern is "is
> this in email address format where the SMTP software can deal with it?"

Agreed.

There is just a nasty bug somewhere:
Adding the unexpected/unsupported(?) marcel <marcel@domain.com> or with quotes "marcel" <marcel@domain.com> in sendbasket/sendshelf are confirmed in the interface with Message sent. And die silently.

The to address/header with the name (quoted and unquoted) pass Email::Address and should actually be correct for SMTP. But fail somewhere between Koha::Email and Email::Sender::Transport::SMTP.
The fact that we use an encapsulated Email::Mime object within Email::Stuffer going to Email::Sender::Simple etc does not make it easier..

Part of the trace below.
Comment 7 Marcel de Rooy 2025-10-17 07:32:45 UTC
[2025/10/17 09:28:41] [WARN] <marcel"@domain.com>: "@" or "." expected after "marcel"


Trace begun at /usr/share/perl5/Email/Sender/Transport/SMTP.pm line 256
Email::Sender::Transport::SMTP::send_email('Email::Sender::Transport::SMTP::Persistent=HASH(0x56178566c960)', 'Email::Abstract=ARRAY(0x5617858cf3f8)', 'HASH(0x561785771838)') called at /usr/share/perl5/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {...}  at /usr/share/perl5/Try/Tiny.pm line 102
eval {...} at /usr/share/perl5/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x561785684d10)', 'Try::Tiny::Catch=REF(0x561784f9de68)') called at /usr/share/perl5/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send('Email::Sender::Transport::SMTP::Persistent=HASH(0x56178566c960)', 'Email::Abstract=ARRAY(0x5617858cf3f8)', 'HASH(0x561785667940)') called at /usr/share/perl5/Email/Sender/Simple.pm line 119
Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abstract=ARRAY(0x5617858cf3f8)', 'HASH(0x561785797560)') called at /usr/share/perl5/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {...}  at /usr/share/perl5/Try/Tiny.pm line 102
eval {...} at /usr/share/perl5/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x56178576c9a0)', 'Try::Tiny::Catch=REF(0x56178566efd0)') called at /usr/share/perl5/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Email::MIME=HASH(0x5617842f0960)', 'HASH(0x56177f79d1e8)') called at /usr/share/perl5/Email/Stuffer.pm line 784
Email::Stuffer::send_or_die('Koha::Email=HASH(0x561784f645f0)', 'HASH(0x5617856681e0)') called at /usr/share/koha/Koha/Email.pm line 237
Koha::Email::send_or_die('Koha::Email=HASH(0x561784f645f0)', 'HASH(0x5617856681e0)') called at /usr/share/koha/C4/Letters.pm line 1573
C4::Letters::try {...}  at /usr/share/perl5/Try/Tiny.pm line 100
eval {...} at /usr/share/perl5/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x561782f0aa40)', 'Try::Tiny::Catch=REF(0x561785771ad8)') called at /usr/share/koha/C4/Letters.pm line 1595
C4::Letters::_send_message_by_email('HASH(0x561785669e90)', undef, undef, undef, 'HASH(0x5617855899e0)') called at /usr/share/koha/C4/Letters.pm line 1077
C4::Letters::SendQueuedMessages('HASH(0x561785559468)') called at /usr/share/koha/opac/opac-sendshelf.pl line 122
eval {...} at /usr/share/koha/opac/opac-sendshelf.pl line 2