I use the SMTP module for sending various notification emails from the websites.
With one domain everything is fine, but with multiple domains one will generally want different SMTP servers for different domains.
That is, one needs some way to specify different "SMTP Authentication Support" settings for each domain:
Example:
Domain 1:
SMTP server: smtp.gmail.com
SMTP port: 465
Use encrypted protocol: Use SSL
Username: noreply@domain-one.com
Password: ****
E-mail from Address: noreply@domain-one.com
E-mail from name: Company 1
Domain 2:
SMTP server: smtp.gmail.com
SMTP port: 465
Use encrypted protocol: Use SSL
Username: noreply@domain-two.com
Password: ****
E-mail from Address: noreply@domain-two.com
E-mail from name: Company 2
How could one achieve that?
Comments
Comment #1
agentrickardIt appears that SMTP module stores all its data in the {variables} table. You can simply user Domain Settings module to store information per-domain, using the SMTP module's existing settings form.
Comment #2
koyama commentedThanks, agent, for pointing me in the right direction.
In case others need this, the solution was to use
hook_domainconf()to expand the "Domain site settings" atadmin/build/domain/conf/2so you get SMTP settings for the additional domains. I put this in a custom module, mymodule.module, copying almost directly the form from smtp.module:
Alternatively, I guess you could also hack the smtp module and put the above function at the end of the file
sites/all/modules/smtp.moduleasfunction smtp_domainconf()On a side note I noticed that one has to visit
admin/build/domain/conf/2from the domain one is about to configure. Otherwise it will load the wrong values into the form. For example, if you are configuring SMTP settings fordomain-two.com, you should visit:http://domain-two.com/admin/build/domain/conf/2and not
http://domain-one.com/admin/build/domain/conf/2Environment:
Comment #3
agentrickardThat's by design. They should not be the 'wrong' values, just the default values (from the primary domain) if you haven't set them for domain two yet.
If you're going to do it this way, I suggest using hook_domainbatch(), which also gives you a batch settings page.
You might also submit a patch to SMTP module.
Comment #5
drusite commentedDoes it work for Drupal 7? Are there any particularities which must be taken into account? Perhaps something must be changed to avoid some problems?
Comment #6
drusite commentedIs it possible to use smtp server per role (for every role the different server must be used)