SMTP Mailer without community subdomain

Hi,

I have configured smtp mailer but i have noticed that the community sub domain is automatically added before the main domain, how can override that ?

This in production fyi
cheers

Hi @wolfieorama,

I’m not sure exactly what you mean? Can you explain a bit further? Is it a link in the HTML, or something in the header? Where is the subdomain being added that you’d like to remove?

Thanks,
Dan

Hi @mooreds

the link is being added at the beginning of every generated link in the email see example:

Hello john,
You need to confirm your email address.
Alternatively you can copy the following link to your browser’s address bar:
http://nest.mymaindomanishere/en/people/confirmation?confirmation_token=dUNZTVXfdUVYwxes

the nest. bit is added automatically … i want to remove that

Hmmm. I’m not quite sure why you’d want to remove it, because I’m not sure that link will work after you remove it (unless you’re going to put a redirect in at mymaindomainishere.com to the sharetribe app at nest.mymaindomainishere.com).

But the code that generates ‘nest.mymaindomainishere.com’ is email_confirmation in app/mailers/person_mailer.rb, specifically this line: @host = community.full_domain

So you can modify that line to remove the domain. Or you can try changing your community’s domain in the database, though I’m not sure what ramifications that will have.

HTH.

thanks, i coldnt trace person_mailer.rb, i am using the open source one and have setup evrything from scratch i dont want to use nest.mydomainI just want my domain

thanks for that

@host for me will be domain only

1 Like

I see what you’re saying @wolfieorama.

Same thing is happening to me on Heroku production.

the confirmation link comes out on the email as http://[app-name].[app-name].herokuapp.com/en/people/confirmation?confirmation_token=[token]

person_mailer.rb is referencing {community.full_domain}, and somewhere this believe the domain is [app-name][domain.com], but I can’t seem to pinpoint where.

Have tried updating the domain: [heroku-domain] in config.yml for production, as where as directly editing community - domain in the database, with neither working.

Anyone have a fix?

@Jarvis_Johnson the solution was to edited this line in app/mailers/person_mailer.rb, specifically this line: @host = community.full_domain but in as much that worked it also broke something else sorry and cant really remember exactly what it was but will definitely update when i get to it

So here’s how the community domain thing works:

These components affect to the domain:

  • domain in config.yml
  • communities.ident in communities table
  • communities.domain in communities table
  • commnunities.use_domain in communities table

By default, the domain in config.yml and communities.ident will form the full_domain. For example, if your domain in config.yml is mydomain.com and your communities.ident is mymarketplace, the full domain is mymarketplace.mydomain.com.

If you don’t want to use the subdomain, but want to instead use the domain e.g. www.mymarketplace.com, you need to add www.mymarketplace.com to the communities.domain column in communities table AND turn on the communities.use_domain boolean.

So if your app is running in Heroku in address mymarketplace.herokuapp.com you can either:

  1. Set domain in config.yml to herokuapp.com and set the communities.ident to mymarpetlace
  2. Set the communities.domain to mymarketplace.herokuapp.com and set the communities.use_domain to true

I’d recommend the option number 2. The option 1 is mainly meant for multimarketplace setup (e.g. sharetribe.com has sharetribe.com as the domain in config.yml and then new trial URL is the ident + sharetribe.com)

This is also documented in the README: https://github.com/sharetribe/sharetribe#setting-your-domain Do you think the documentation there is enough or should we add some more clarification there?

2 Likes

Ah, makes perfect sense now @rap1ds. Thanks for another great response. And cheers @wolfieorama.

I definitely understand the documentation now, but yes it could be more clear.

Something to the effect of ‘Your marketplace’s domain will default to a subdomain - [community-ident.domain] unless you turn on the use_domain setting; change that value if you want a custom domain.’

I suppose yeah a shortened version of your answer would be good!

1 Like

Clarification here:

The 'domain: ’ setting in config.yml takes precedence even if you switch the use_domain setting to true in the communities table of the database.

So I commented out my domain settings in config.yml and changed use_domain setting, now I have my domain working.

I don’t think this is the case (or at least it shouldn’t be, assuming there’s no bug). In fact, it’s the opposite: communities.domain takes precedence over the domain in config.yml if communities.use_domain is switched on. You shouldn’t need to comment out the domain setting in config.yml.

Did you really have to comment out the domain setting in config.yml to get this working properly?

I did but I don’t think there’s any bug, just probably have gotten things a little mixed up in my version!