0

I have a contact form. The smtp module is installed on the project. For smtp service we use smtp.gmail.com.

smtp module will collect all sendings and redirect them to the mail service, but my task is to add it to STORES> Configuration> GENERAL> Contacts> Email Options second mail. But there was validation

enter image description here

If you remove the validation and paste the mail as on the screen

enter image description here

then when submitting the form there will be such an error 5.1.2 The recipient address <[email protected] [email protected] 5.1.2> is not a valid RFC-5321 address. m21sm455969lfh. 39 - gsmtp

1 Answer 1

3

You will need to extend the framework.

Each email needs to be individually added as a destination address.

I do this for CC address in this extension

https://github.com/DominicWatts/EmailCC/blob/master/Plugin/Magento/Framework/Mail/Template/TransportBuilder.php#L51

There isn't a quick and easy method I can show you

https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/Mail/Message.php#L118-L122

public function addTo($toAddress)
{
    $this->zendMessage->addTo($toAddress);
    return $this;
}

You'd need to adapt something like this https://github.com/DominicWatts/ContactAttachment/blob/master/Rewrite/Magento/Contact/Controller/Index/Post.php#L215

Or you can use something like this

https://www.magenticity.com/contact-inquiry-manager-magento2.html

Might be more cost effective/easier for you

Update

I created an extension

https://github.com/DominicWatts/ContactCc

Not as clean as I would like but you can see I build different sends based on configuration.

2
  • i should create a new module and rewrite those 3 files? Commented Sep 23, 2019 at 6:20
  • @annkarsksya check my updated answer Commented Sep 23, 2019 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.