Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change form subject and sender #221

Closed
suntrop opened this issue Nov 28, 2014 · 7 comments
Closed

Change form subject and sender #221

suntrop opened this issue Nov 28, 2014 · 7 comments

Comments

@suntrop
Copy link

suntrop commented Nov 28, 2014

Is there any way to change params like subject, sender?

@piotr-cz
Copy link
Contributor

piotr-cz commented Dec 1, 2014

  • The easiest way ATM is by adding hidden fields named __mailsubject and form_options[from] to your form.
    I haven't tried it yet, but it looks so from inspecting Form module.
  • You could also alter the $_REQUEST in your custom form validation but it's a hack.

Both methods are not documented so may go away in future versions
Best way would be to add such option in admin.

@suntrop
Copy link
Author

suntrop commented Dec 1, 2014

Piotr, thanks for your help. Works well with this …
input type="hidden" name="__mailsubject" value="My Subject"
input type="hidden" name="form_options[from]" value="sender@example.com"

I had a look at the same code, but didn't know how to use it within the html form.

@piotr-cz
Copy link
Contributor

piotr-cz commented Dec 1, 2014

You may set global from address in configuration, I'll be posting a PR for setting fromName.
For mail subject, I guess it makes sense to add such option in Forms model

@suntrop
Copy link
Author

suntrop commented Dec 1, 2014

👍 Sounds good! I checked the config too, but have no clue how to add implement a new option :-)

@piotr-cz
Copy link
Contributor

piotr-cz commented Dec 2, 2014

Actually it's quite easy, you just pass on additional config value in the line setting from to:

$message->setFrom(
    isset($options['from']) ? $options['from'] : 'mailer@'.(isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : 'localhost'),
    isset($options['fromName']) ? $options['fromName'] : false
);

Now you can pass on fromName inside of a form or a custom config file.

BTW: I don't like the option to set mailer values inside the form because IMHO it's as security issue but that's at lease something before there's dedicated field in admin.

@suntrop
Copy link
Author

suntrop commented Dec 3, 2014

Thanks for your tips! I got it working. Some settings should be outside the user scope (i.e. not within the html form) – since From isn't crucial, I like it more than editing core files – sometimes :-)

@piotr-cz
Copy link
Contributor

I've submitted the feature in #223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants