Share all details about your problem, including any error messages you may have received.
We’re changing the email settings of an IIQ instance from type SMTP to HTTP/OAuth.
The new configuration uses an Entra ID app registration that has Mail.Send rights on shared mailboxes. It is working, but we see one functional difference.
In the old SMTP setup, we could change the email address the message was sent from on a per-template basis. For a password mail, for example, we could include "<From>helpdesk@company.com</From>" in the emailTemplate XML object. This doesn’t seem to have any effect anymore. All mails are sent from the address of the shared mailbox configured in the email settings.
We made sure the app registration used in the email config has access to both shared mailboxes we want to send from. If we change the config to use the helpdesk address, that also works, but then of course all mails are sent from that address.
Does anyone know of a way to use a different “from” address based on the emailTemplate being used (in an HTTP/OAuth-type email config)?
What do you mean exactly with “using setFrom(email) method”?
Searching the javadoc I only see that method on Class EmailTemplate. The EmailTemplate object I’m using has a “from” field already, so I’m not sure what setting it explicitly in the code again will add?
But to test I added this check:
if (template.getFrom() == null || template.getFrom().trim().isEmpty()) {
template.setFrom(defaultFromAddress);
}
I’m sending the mail like this:
EmailOptions options = new EmailOptions(recipient, args);
context.sendEmailNotification(template, options);
Same behaviour.
Is there another way I could send it programmatically to try?
As the email config (in global setting → IIQ config → notification settings → email service endpoint) uses the endpoint that has emailaddress in it https://graph.microsoft.com/v1.0/users/<email_address>/sendMail it’s not possible to change the from address for each template.
A workaround would be to update the sytemconfig before and after sending the email, but it can cause other emails triggered by the system to use the same from address. A proper solution would be to write a custom emailnotifier that extends the HTTPEmailNotifier and override the sendEmailNotification method to honor the from address from the template and construct the graph endpoint and send email.