diff --git a/plugins/calendar/config.inc.php.dist b/plugins/calendar/config.inc.php.dist index 115101cc..449041cb 100644 --- a/plugins/calendar/config.inc.php.dist +++ b/plugins/calendar/config.inc.php.dist @@ -110,7 +110,9 @@ $rcmail_config['calendar_allow_invite_shared'] = false; // enable asynchronous free-busy triggering after data changed $rcmail_config['calendar_freebusy_trigger'] = false; -// SMTP server host used to send (anonymous) itip messages +// SMTP server host used to send (anonymous) itip messages. +// Set to '' in order to use PHP's mail() function for email delivery. +// To override the SMTP port or connection method, provide a full URL like 'tls://somehost:587' $rcmail_config['calendar_itip_smtp_server'] = null; // SMTP username used to send (anonymous) itip messages diff --git a/plugins/calendar/lib/calendar_itip.php b/plugins/calendar/lib/calendar_itip.php index dc9a6922..90110730 100644 --- a/plugins/calendar/lib/calendar_itip.php +++ b/plugins/calendar/lib/calendar_itip.php @@ -37,6 +37,7 @@ class calendar_itip $this->rc = $cal->rc; $this->sender = $identity ? $identity : $this->rc->user->get_identity(); + $this->cal->add_hook('message_before_send', array($this, 'before_send_hook')); $this->cal->add_hook('smtp_connect', array($this, 'smtp_connect_hook')); } @@ -115,6 +116,20 @@ class calendar_itip return $sent; } + /** + * Plugin hook triggered by rcube::deliver_message() before delivering a message. + * Here we can set the 'smtp_server' config option to '' in order to use + * PHP's mail() function for unauthenticated email sending. + */ + public function before_send_hook($p) + { + if ($this->itip_send && !$this->rc->user->ID && $this->rc->config->get('calendar_itip_smtp_server', null) === '') { + $this->rc->config->set('smtp_server', ''); + } + + return $p; + } + /** * Plugin hook to alter SMTP authentication. * This is used if iTip messages are to be sent from an unauthenticated session