# How to create a Campaign to send one out of 30 emails randomly

**URL:** <https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274>\
**Category:** General Discussion\
**Created:** [January 10, 2020, 9:46pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274 "2020-01-10T21:46:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ritesh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ritesh/32/703_2.png) [@ritesh](https://forum.mautic.org/u/ritesh)\
**Post date:** [January 10, 2020, 9:46pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/1 "2020-01-10T21:46:29Z")

</div>

I have created around 30 emails, each one of them has one or two “Tips” on how to use my certain products. Now, I want to build a Campaign to send one of the 30 emails randomly to all contacts in a segment on every few days.

Any idea how can I get it done?

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 29, 2020, 7:35pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/2 "2020-03-29T19:35:49Z")

</div>

Do you want the contacts to receive all emails eventually or only a portion of them?

---

<div class="post-metadata">

**Author:** ![mayanktiwaridotcom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mayanktiwaridotcom/32/1501_2.png) [@mayanktiwaridotcom](https://forum.mautic.org/u/mayanktiwaridotcom)\
**Post date:** [March 31, 2020, 7:00pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/3 "2020-03-31T19:00:30Z")

</div>

If you can develop a plugin then I think there might be a way. you can subscribe to campaign trigger event and change the email you wish to send.

If you want to send unique email every time then you’ll have to keep a count(may be store email ids in a custom field and match to ensure last sent mail wasn’t this), else if you want to choose randomly that would be fairly easy with event subscriber approach.

---

<div class="post-metadata">

**Author:** ![ritesh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ritesh/32/703_2.png) [@ritesh](https://forum.mautic.org/u/ritesh)\
**Post date:** [May 6, 2020, 3:21pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/4 "2020-05-06T15:21:09Z")

</div>

all emails should go eventually and later cycle should start again… “cycle” means not in the exact same sequence of emails sent in the first cycle but all 30 emails should go again in random order.

---

<div class="post-metadata">

**Author:** ![ritesh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ritesh/32/703_2.png) [@ritesh](https://forum.mautic.org/u/ritesh)\
**Post date:** [May 6, 2020, 3:22pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/5 "2020-05-06T15:22:18Z")

</div>

can you please provide anymore hint on this?

---

<div class="post-metadata">

**Author:** ![mayanktiwaridotcom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mayanktiwaridotcom/32/1501_2.png) [@mayanktiwaridotcom](https://forum.mautic.org/u/mayanktiwaridotcom)\
**Post date:** [May 6, 2020, 5:13pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/6 "2020-05-06T17:13:42Z")

</div>

What i mean is you will need to develop a plugin which randomly take a user from either whole system of a segment and trigger email.

for more information on developing plugin you can refer to [https://developer.mautic.org/#plugins](https://developer.mautic.org/#plugins)

what I think should be a good idea is:  
create a custom campaign action([https://developer.mautic.org/#extending-campaigns](https://developer.mautic.org/#extending-campaigns)) let’s say “Send Random Email”.  
Then set up a campaign with segment and this action.

finally your action should be to choose random email from your email list and send email(via this action). [https://developer.mautic.org/#models](https://developer.mautic.org/#models)(see this example for sending emails from code).

---

<div class="post-metadata">

**Author:** ![ritesh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ritesh/32/703_2.png) [@ritesh](https://forum.mautic.org/u/ritesh)\
**Post date:** [May 6, 2020, 8:29pm UTC](https://forum.mautic.org/t/how-to-create-a-campaign-to-send-one-out-of-30-emails-randomly/12274/7 "2020-05-06T20:29:31Z")

</div>

Great job buddy… let me look into it…

Thanks a ton!
