-
Notifications
You must be signed in to change notification settings - Fork 78
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
Same email address when sending notification mails from the forms. This is not supported by many mail providers. #350
Comments
You can already define whatever email address you want in your The I'm not sure what the issue really is. What email providers are blocking here what correctly (which headers in which combination)? Can you provide more information how we can reproduce here, so we maybe can provide here better default settings. |
I want to keep SULU_ADMIN_MAIL for user administration and such, which is [email protected]. Also i use the main organisation email address which is also [email protected]. But because i use a dynamic form with all fields left empty sender email/name |
If i change the sender email it also keeps the same mail as the main organisation is the same email address. Sadly there is no option to just use for the dynamic form another notification FROM email address so i can use [email protected] instead. |
If I understand you correctly this works in your case: sulu_form:
mail:
from: "[email protected]"
to: "[email protected]"
sender: "[email protected]" But this fails: sulu_form:
mail:
from: "[email protected]"
to: "[email protected]"
sender: "[email protected]" Think then the easiest fix would be check in the FormBundle to set the Pinging here also @lkeijmel as he implemented the |
I need to take a deep dive into Sulu again as it's also a couple of years ago I've used it. At first glance the suggestion of @alexander-schranz (only add @creatiombe can you remove the |
Hey in a follow up, yes i did fix it with overriding the SuluMailHelper with another service. I reconfigured the sendMail function the following code: public function sendMail(
$subject,
$body,
$toMail = null,
$fromMail = null,
bool $html = true,
$replyTo = null,
array $attachments = [],
$ccMail = [],
$bccMail = [],
$plainText = null
): int {
$message = new Email();
$fromMail = $fromMail ?: $this->fromMail;
$toMail = $toMail ?: $this->toMail;
if ($toMail instanceof \array && 1 === count($toMail)) {
$toMail = $toMail[0];
}
if ($fromMail instanceof \array && 1 === count($fromMail)) {
$fromMail = $fromMail[0];
}
// Check if from and to are the same
if (
!($toMail instanceof \array) &&
!($fromMail instanceof \array) &&
$toMail === $fromMail
) {
// Replace the email address with a noreply address
$fromMail = preg_replace('/^(.*?)@/', 'noreply@', $fromMail);
}
$this->setHeaders(
$message,
$subject ?: '',
$this->parseToAddresses($fromMail),
$this->parseToAddresses($toMail),
$this->parseToAddresses($replyTo),
$this->parseToAddresses($ccMail),
$this->parseToAddresses($bccMail),
$this->sender ? new Address($this->sender) : null
);
$this->setBody($message, $html, $body, $plainText);
$this->setAttachments($message, $attachments);
$this->logMessage(
$fromMail ?: $this->fromMail,
$toMail ?: $this->toMail,
$replyTo,
$subject ?: '',
$ccMail,
$bccMail,
$plainText
);
$this->mailer->send($message);
return 0;
} Also i found out there was a setting wrong with mailgun mailer from symfony i needed to set ?region=eu. But still then it was mailing from the same email address. I just tested your settings and indeed it seems to work. But i would advice to use a check just in case same email adresses are set. I will try to make time next week to make a pull request for it. |
Good to hear that! When adding the small documentation change I didn't think of it to make it more clear how and why the I will take a look at it and make a PR for it as well. |
Actual Behavior
How does it behave at the moment?
It uses the same SULU_ADMIN_EMAIL for notifications and success mails.
Expected Behavior
What is the behavior you expect?
May mailing services block same domain mails, so notification system is broken if the main organisation mail is the same as the SULU_ADMIN_MAIL. For example i only want a [email protected] for environment variable for SULU_ADMIN_EMAIL. But if this is the same as the main organisation mail adres, there is no possibility to change this.
Steps to Reproduce
What are the steps to reproduce this bug? Please add code examples,
screenshots or links to GitHub repositories that reproduce the problem.
Possible Solutions
If you have already ideas how to solve the issue, add them here.
Like i thought and got suggested by chatgpt, i need to override the form handler of the form bundle.
A possible solution would be to have in the sulu_form configuration a notification_from email address override that handles same email addresses. Or if the from and to is the same in the form handler, override the same email adress with a noreply to avoid problems.
The text was updated successfully, but these errors were encountered: