Selecting delivery server for transactional email

I've tried some settings, but cannot find out how to do so:

For a specific client, with a specific domain let's say 'clientdomain.com', we've got specific transactional emails.
It is needed to sent these specific transactional emails over a specific delivery server. Other email should sent over the 'standard' delivery service for that customer.
We sent transactional email using the 2.0 API

As far as I can see there is no option to select a specific delivery server through the API call.

How can we achieve the above so that, for a selection of (transactional) emails, we can select a specific delivery server?
 
Doesnt it work to create a delivery server only for transactional emails, and assign that server to that customer, so all transactional emails for that customer go out using that server?
 
Maybe it does, but it is needed to only sent this specific (transactional) mails over a specific delivery server.
The case is: invoices need to be sent over a more secure (and expensive) environment, others can use the regular delivery server

For these invoices (also for other transactional emails) we use the transactional email API
Only uniqueness is the domain which is sent from, this domain differs from our other sendings.

Can we set the selection of a delivery server purely based on the mailFrom domain used (so that MailWizz sents all email with a specific domain used in the mailFrom from that server while we exclude it in the other delivery servers) OR as a setting while sending the email through the (transactional)API?
 
Is there something I can do in the code, or something else what realizes what we are looking for?

It is important for us to stay within the customer environment and that this specific transactional email is being sent over a specific SMTP server:
Only uniqueness is the domain which is sent from, this domain differs from our other sendings.

- Can we select on the mailFrom variable to switch sending over a specific delivery server?
- Can we push the desired delivery server to send with the API call?
- Can we put something in the email content (hidden) which can be used to select the correct delivery server?
- maybe even some manually altered code in one of the php files?
 
I am glad you asked, if you can do it programatically, then you can add a code like below in apps/init-custom.php:
PHP:
hooks()->addFilter('delivery_servers_before_pick_server', function(?DeliveryServer $server = null, CAttributeCollection $hookParams) {
    
    $targetCustomerId = 12345; // change to the right customer id
    $targetServerId = 2222; // change to the right server id
    
    if (
        $hookParams->deliveryObject instanceof TransactionalEmail &&
        $hookParams->deliveryObject->customer_id === $targetCustomerId
    ) {
        $server = DeliveryServer::model()->findByPk($targetServerId);
    }
    
    return $server;
});
In the above code, $hookParams->deliveryObject is an instance of TransactionalEmail model(see /apps/common/models/TransactionalEmail.php), where you have access to all the transactional email params to make a decision if you have to load that delivery server or not.
 
Back
Top