I have a straight forward Java mailer program using Jakarta Mail API to send emails. In case no SMTP hosting server is specified, I take the first recipient from the TO: field to search the highest priority MX record to send the email.
But if the TO: or CC: or BCC: fields have multiple recipients from different domains (e.g. [email protected] and [email protected]), how to I process them? I don’t think I can still send them to the first recipients domain, as this server would then need to relay.
I know, I could sort out all recipient domains and send them individually but then the recipients will not be notified of the foreign recipients.
How can I solve this?