Hướng dẫn gửi email dựa trên select option trong Contact Form 7
28th Jul 2021Chúng tôi sẽ hướng dẫn bạn cách gửi email cho những người khác nhau dựa trên lựa chọn thả xuống trên Biểu mẫu liên hệ 7 trong Wordpress.
Chúng tôi muốn làm gì?
Giả sử rằng bạn là chủ sở hữu của một công ty có uy tín. Công ty của bạn có các văn phòng / phòng ban khác nhau ở các thành phố khác nhau.
So you want to submit all queries to the relevant office/department. Let’s say you have “Administrator”, “Support”, “Technical” and “Sales” department.
Now, Let’s set up a Contact Form 7 in a way so you will receive emails on above mentioned offices/departments.
Selectable Recipient in Contact Form 7
Create dropdown with options “Administrator”, “Support”, “Technical” and “Sales” in Contact Form 7 as following:
[select your-recipient "Administrator" "Support" "Technical" "Sales"]
Now, add email addresses as a value to each option using pipe (|) sign.
[select your-recipient "Administrator|[email protected]" "Support|[email protected]" "Technical|[email protected]" "Sales|[email protected]"]
Selectable Recipient Dropdown Contact Form 7
Go to the “Mail” tab and set the mail tag "[your-recipient]" into the To: field. This setting ensures that the email is sent to the specified email address that the sender selected. Don’t take a tension about invalid mailbox syntax.
Selectable Recipient Contact form 7 To Field
We are done now. Try to submit 2-3 mails by selecting a different dropdown option. Make sure that your mail sending mechanism working. If not then install any simple SMTP plugin to make it work.
Additional Information
To get the value before pipe (|) sign use [your-recipient] as we already did in To: field of Mail tab.
To get the value after pipe (|) sign use [_raw_{field name}]. In our case, {field name} is your-recipient. So finally, it will be [_raw_your-recipient]. This can be handy in the Message body.
That’s it for now. We hope this post helps you to learn how to send emails to different people based on dropdown selection in Contact Form 7.
Add new comment