CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Use -s option when sending CiviMail via CLI
Pages: [1]

Author Topic: Use -s option when sending CiviMail via CLI  (Read 1756 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Use -s option when sending CiviMail via CLI
October 29, 2013, 07:32:05 pm
Use the "-s example.com" option when sending CiviMails via CLI, where example.com is your site's host name.

Otherwise relative links in the "text" version of the email get translated as "http://localhost/relative-url".

Similarly, don't use "-s default" if this is your default Drupal installation. Otherwise you get "http://default/relative-url".

The CiviCRM documentation is wrong at http://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs because -s is not the site-directory; it is the host name.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Use -s option when sending CiviMail via CLI
October 30, 2013, 01:00:31 am
updated wiki, changed to site name / host name.

Kurund
Found this reply helpful? Support CiviCRM

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Use -s option when sending CiviMail via CLI
October 31, 2013, 10:51:10 pm
@kurund,

I think the change needs to go further. I've edited the page myself. Could you check I've not gone too far?

Ken

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Use -s option when sending CiviMail via CLI
October 31, 2013, 11:30:32 pm
Hi,

I'm the guilty one for that -s syntax. It used to work fine by putting the folder instead of the name, but nowadays I switched using drush, that does a much better job, including not needing to put the password.

I suggest we change and say if you do drupal, use the drush approach.
For the other cmses, is the -s multisite relevant and working? if it's not the case, we shoudn't document that -s option and mention that the way for multisite is to use drush.

What do you think?

X+


X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Use -s option when sending CiviMail via CLI
November 01, 2013, 01:02:59 am
@xavier,

The multisite reference is misleading. Since CLI doesn't run in a browser context, and some CiviCRM jobs expect that it does, the -s parameter is needed in all cases.

The only use of this parameter in the code that I can see is ...
Code: [Select]
    $_SERVER['HTTP_HOST'] = $this->_site;
... on line 186 of bin/cli.class.php

Any code invoked by CLI that uses $_SERVER['HTTP_HOST'] will break if this parameter is not set. The wrinkle with multisite is deciding which FQDN to use when running the job. I assume drush resolves that with the -l parameter?

Ken

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Use -s option when sending CiviMail via CLI
November 01, 2013, 03:02:55 am
Good point thanks.

I'm wondering if we are not hitting a core bug:
we need to set up civi url in the civicrm setting (CIVICRM_UF_BASEURL)
most of the code is using it, but you hit some that use the HTTP_HOST

Either we don't need CIVICRM_UF_BASEURL and we remove it (bad idea) or we remove references to HTTP_HOST, but using both is the worse situation.

@ken,

What is not working? We should fix it so it uses CIVICRM_UF_BASEURL

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Use -s option when sending CiviMail via CLI
November 01, 2013, 03:29:44 am
Ken,

thanks for updating the wiki, looks good to me

Kurund
Found this reply helpful? Support CiviCRM

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Use -s option when sending CiviMail via CLI
November 01, 2013, 04:46:34 am
@xavier,

The issue I found is that the html2text package uses $_SERVER['HTTP_HOST']. Tinkering with packages seems to be a bad idea (and a number of them refer to $_SERVER['HTTP_HOST'] such as dompdf, html2text, kcfinder, Net, Pager, and tcpdf). Perhaps the best bet is to change cli.class.php to default $_SERVER['HTTP_HOST'] to the server name contained in the CIVICRM_UF_BASEURL, rather than 'localhost' as is currently done. That would minimise the need to use the -s parameter.

Ken

PS: all the other references to $_SERVER['HTTP_HOST'] are "bootstrap" code (/CRM/Core/Config.php, /CRM/Utils/System/*, /install/* code, and civicrm.config.php) which probably needn't change.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Use -s option when sending CiviMail via CLI
November 01, 2013, 04:50:34 am
@ken,

That's indeed the best solution once civi is initialised to

$_SERVER['HTTP_HOST'] = CIVICRM_UF_BASEURL;

 when it's the cli. Could you test and PR?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Use -s option when sending CiviMail via CLI
November 02, 2013, 03:38:01 am
http://github.com/civicrm/civicrm-core/pull/1893

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Use -s option when sending CiviMail via CLI
November 03, 2013, 09:03:31 am
kool, thanks :)
Found this reply helpful? Support CiviCRM

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Use -s option when sending CiviMail via CLI
November 17, 2013, 08:55:25 pm
Created PR https://github.com/civicrm/civicrm-core/pull/2011 against civicrm:4.4

bmw

  • I post occasionally
  • **
  • Posts: 103
  • Karma: 4
    • Alcohol Justice - The Industry Watchdog
  • CiviCRM version: 4.5.8
  • CMS version: Joomla! 3.4.0
  • MySQL version: 5.5.42-cli
  • PHP version: 5.3.27
A Request: Re: Use -s option when sending CiviMail via CLI
November 25, 2013, 02:45:08 pm
A request:
For some reason that is becoming obvious is the consistency of Drupal references in the documentation as if that is the only platform CiviCRM is being built and maintained for. Unfortunately, I am not application developer enough to help with other platforms, ie, Wordpress and Joomla.

It would be very helpful and, continued, inviting to make separate references in the Wiki and other documentation for specific platforms leaving the basic information as general. For those platforms that do not have current references, a simple notation like "Not available. Feel free to make an entry if tested and confirmed."

Thank you.
Bruce Wolfe, M.S.W., CIO
Alcohol Justice, 501(c)3

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Use -s option when sending CiviMail via CLI
November 26, 2013, 12:32:45 am
Hi,

Most of the times, it works the same no matter the CMS. if you see a page that isn't the case, please edit it, it's a wiki, everyone can contribute (even to add didn't work on xy and seem to be drupal specific, please completeif tested and confirmed on xy).
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Use -s option when sending CiviMail via CLI

This forum was archived on 2017-11-26.