Separate Send from and Reply to email addresses

Mehr
1 Monat 3 Wochen her #193994 von kclingerman
Thank you all for the feedback, I really like LimeSurvey and I understand Denis' point of view some noob coming in and doing things wrong :P

Thank you for providing a better way for people to accomplish this in the future Denis!

I will try to see if I can get together a plugin which does exactly what I want and share it with the community. I am no expert in PHP but I hope I can contribute!
Folgende Benutzer bedankten sich: holch

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #193995 von DenisChenu
No, @kclingerman : @holch have right. Maybe I was right on the substance, but clearly not on the form.

Otherwise: I criticize the method, not the person. It also happens to me to write stupid and silly things.

For the plugin :
Start with mailSenderToFrom : update it in a new directory inside ./plugins

mailAnswerTo, rename the php file to mailAnswerTo.php
find mailSenderToFrom in the php file to mailAnswerTo, same in config file.

Remove the code here:
github.com/LimeSurvey/LimeSurvey/blob/d6...erToFrom.php#L40-L45

And replace by (for example)

$limeMailer->AddReplyTo(App()->getConfig('siteadminemail'));

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .
Folgende Benutzer bedankten sich: holch

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #194008 von kclingerman
Thank you for the advice!

Can you direct me to some documentation on adding settings to a survey? I would like to be able to set the reply-to address per survey.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #194010 von kclingerman
Hey Denis,

I need some advice on this, I am having a lot of trouble with object oriented php lol. In the below plugin storing the plugin settings is fine, but I don't know how to get that into the $limeMailer->AddReplyTo function. Can you please let me know what I am doing wrong?

Thank you!
<?php
 
class CustomReplyTo extends PluginBase
{
	protected $storage = 'DbStorage';
    static protected $description = 'Set reply-to address';
    static protected $name = 'CustomReplyTo';
 
 
    public function init()
    {
        $this->subscribe('beforeEmail','beforeEmail');
        $this->subscribe('beforeSurveyEmail','beforeEmail');
        $this->subscribe('beforeTokenEmail','beforeEmail');
		// Provides survey specific settings.
        $this->subscribe('beforeSurveySettings');
        // Saves survey specific settings.
        $this->subscribe('newSurveySettings');
    }
 
 
	public function beforeSurveySettings()
		{
			$pluginsettings = $this->getPluginSettings(true);
 
			$event = $this->getEvent();
			$iSurveyID=$event->get('iSurveyID');
			$event->set("surveysettings.{$iSurveyID}", array(
				'name' => get_class($this),
				'settings' => array(
					'customReplyTo' => array(
					'type' => 'string',
					'label' => 'Custom Reply-To:',
					'current' => $this->get('customReplyTo', 'Survey', $event->get('survey'))
					)
				)
			));
		}
	 /**
     * Save the settings
     */
    public function newSurveySettings()
    {
        $event = $this->getEvent();
        foreach ($event->get('settings') as $name => $value)
        {
                $this->set($name, $value, 'Survey', $event->get('survey'));
        }
    }
    /**
     * Set From and Bounce of PHPmailer to siteadminemail
     * @link https://manual.limesurvey.org/BeforeTokenEmail
     */
    public function beforeEmail()
    {
        $emailsmtpuser = Yii::app()->getConfig('emailsmtpuser');
        if(empty($emailsmtpuser)) {
            return;
        }
        $limeMailer = $this->getEvent()->get('mailer');
		$limeMailer->AddReplyTo($this->get('customReplyTo', 'Survey', $event->get('survey')));
        $this->getEvent()->set('updateDisable',$updateDisable);
    }
}

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #194022 von DenisChenu
You have to get the current sid if exist.

See : manual.limesurvey.org/BeforeSurveyEmail

After
$this->get('customReplyTo', 'Survey', $surveyId);
give you the value set.

If you need a global one $this->get('customReplyTo');

finally something like this
public function beforeEmail()
    {
        /* Global one (if you have a global settings array */
        $customReplyTo = $this->get('customReplyTo');
        /* get the current survey id */
        $surveyId = $this->getEvent()->get('survey'); // Survey id as integer
        if($surveyId) {
            /* Maybe use globalk is empty ( == "") */
            $customReplyTo = $this->get('customReplyTo', 'Survey', $surveyId);
        }
        if(empty($customReplyTo)) {
            return;
        }
        $limeMailer = $this->getEvent()->get('mailer');
        $limeMailer->AddReplyTo($customReplyTo);
    }

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #194024 von DenisChenu
Move topic to Development :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 3 Wochen her #194168 von kclingerman
Thank you Denis, this works and helps me understand how to get and use setting values.

The only issue I see now is when the plugin customToken is enabled, my customReplyTo plugin does not show up under the "Simple plugins" menu, only the customToken setting is shown. Is this an issue with limesurvey, or how the plugin was created?


Here is the full source as I am currently using it:
class CustomReplyTo extends PluginBase
{
	protected $storage = 'DbStorage';
    static protected $description = 'Set reply-to address';
    static protected $name = 'CustomReplyTo';
 
 
    public function init()
    {
        $this->subscribe('beforeEmail','beforeEmail');
        $this->subscribe('beforeSurveyEmail','beforeEmail');
        $this->subscribe('beforeTokenEmail','beforeEmail');
		// Provides survey specific settings.
        $this->subscribe('beforeSurveySettings');
        // Saves survey specific settings.
        $this->subscribe('newSurveySettings');
    }
 
 
	public function beforeSurveySettings()
		{
			$pluginsettings = $this->getPluginSettings(true);
 
			$event = $this->getEvent();
			$iSurveyID=$event->get('iSurveyID');
			$event->set("surveysettings.{$iSurveyID}", array(
				'name' => get_class($this),
				'settings' => array(
					'customReplyTo' => array(
					'type' => 'string',
					'label' => 'Custom Reply-To:',
					'current' => $this->get('customReplyTo', 'Survey', $event->get('survey'))
					)
				)
			));
		}
	 /**
     * Save the settings
     */
    public function newSurveySettings()
    {
        $event = $this->getEvent();
        foreach ($event->get('settings') as $name => $value)
        {
                $this->set($name, $value, 'Survey', $event->get('survey'));
        }
    }
    /**
     * Set From and Bounce of PHPmailer to siteadminemail
     * @link https://manual.limesurvey.org/BeforeTokenEmail
     */
    public function beforeEmail()
    {
        /* Global one (if you have a global settings array */
        $customReplyTo = $this->get('customReplyTo');
        /* get the current survey id */
        $surveyId = $this->getEvent()->get('survey'); // Survey id as integer
        if($surveyId) {
            /* Maybe use globalk is empty ( == "") */
            $customReplyTo = $this->get('customReplyTo', 'Survey', $surveyId);
        }
        if(empty($customReplyTo)) {
            return;
        }
        $limeMailer = $this->getEvent()->get('mailer');
        $limeMailer->AddReplyTo($customReplyTo);
    }
}

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her - 1 Monat 2 Wochen her #194218 von DenisChenu

kclingerman schrieb: The only issue I see now is when the plugin customToken is enabled, my customReplyTo plugin does not show up under the "Simple plugins" menu, only the customToken setting is shown. Is this an issue with limesurvey, or how the plugin was created?

Unsure,

can be a LimeSurvey issue.

You mean you have only one Simple plugin settings shown ?

I think there are an issue in you code.
$oEvent->set("surveysettings.{$this->id}", array(

and not
$event->set("surveysettings.{$iSurveyID}", array(

Because you muts add settings for YOUR plugin.

It's an issue in the core plugin
github.com/LimeSurvey/LimeSurvey/blob/4c.../customToken.php#L85

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .
Letzte Änderung: 1 Monat 2 Wochen her von DenisChenu.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #194219 von DenisChenu

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha