I just wonder if there is any option to set a "from" address in the Contact Form extension?
The reason I ask is that I see a lot of contact email is marked as spam, as the "from" address is faked and the "Your e-mail" address is used.
Like this:
Sender email is commonly abused enduser mail provider
'From' xxxx does not match 'Received' headers
I rather would like to use noreply@some.domain
BTW .. the Reply-To is of course the "Your e-mail" address.
Thanks,
Matthijs
Offline
Hi,
I struggled with this one and needed the same: my piwigo site webmaster email is not accepted by my SMTP service, and I needed to edit the "From" field from which the Contact Form plugin sends an email.
I assume I'm not the only one with this problem and I found a solution. This post is outdated but the forum is still useful for future users making queries.
Edit your email and paste this code in the 'Personal Plugin' space of the 'LocalFiles Editor' plugin.
/*
// For contact forms emails only: Sends as 'myotheremail@myotherdomain.com because by default it uses pwg_mail() and then my VPS php mail (), using the default piwigo webmaster email in the FROM field, which is not an approved sender for my SMTP provider
*/
add_event_handler('before_send_mail', 'override_contact_form_from', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
function override_contact_form_from($result, $to, $args, $mail) {
// Only modify ContactForm emails
if (isset($args['subject']) && strpos($args['subject'], '[') === 0) {
// Store original sender info
$original_from = $mail->From;
$original_name = $mail->FromName;
// Override the PHPMailer From field directly
$mail->setFrom('myotheremail@myotherdomain.com', 'Myself Thatworks');
}
return $result;
}This works for the emails sent by the Contact Form plugin.
I had the same problem for notification emails sent by Piwigo itself (e.g. a new user registers, new photos are added). The recommended approach here with the $conf['mail_sender_email'] parameter didn't work for me on Piwigo 16.1.
I used that code instead, also saved in my Personal Plugin, inspired from the Protect Notification plugin
/*
// For piwigo-sent notifications only: Sends as 'myotheremail@myotherdomain.com because by default it uses pwg_mail() and then my VPS php mail (), using the default piwigo webmaster email in the FROM field, which is not an approved sender for my SMTP provider
*/
if (!function_exists('protect_switch_webmaster_email')) {
function protect_switch_webmaster_email($email) {
return 'myotheremail@myotherdomain.com';
}
}
add_event_handler('get_webmaster_mail_address', 'protect_switch_webmaster_email');I hope that helps future watchers!
This could also be integrated in the Piwigo config itself, or the Contact Form plugin itself, since the current documentation at https://doc.piwigo.org/customizing-your … go-gallery reads "If you don't manage to solve the issue, we recommend you uninstall Contact Form."
Offline
I created a pull request for the Piwigo GitHub repository for this problem over a year ago. There have been no responses to this request but I've applied it to my own self-hosted Piwigo instance. It may address your issue.
https://github.com/Piwigo/Piwigo/pull/2266
Offline
MLXXXp wrote:
I created a pull request for the Piwigo GitHub repository for this problem over a year ago. There have been no responses to this request but I've applied it to my own self-hosted Piwigo instance. It may address your issue.
https://github.com/Piwigo/Piwigo/pull/2266
Ah nice, well done! Too bad it's not merged. Indeed today with so much spam and with SPF/DKIM enforced almost everywhere, it's should be important for Piwigo to catchup and not send emails with a From field that a guest visitor can submit.
Until then the PersonalPlugin hook I've shared does the job and is resistant to Piwigo upgrades.
Offline