Sending email through external script

Hi,
I am using NC 16 with nextcloudpi.
I would like to send files per email through an external script. Is there any way to make use of what nextcloud is using when SMTP is configured for nextcloud emails?

I am afraid of using e.g. ssmtp and interfering with nextclouds email functionality.
Can anyone please guide me in the right direction?

Thank you,
Martin