Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
hi all, :)
I'm new to the community :roll:
Thanks for this active community

هاست لینوکس ثبت دامنه طراحی سایت طراحی سایت فروشگاهی طراحی سایت شرکتی
I am trying to build code to send a news flash to external subscribers to our site.
سئو سایت طراحی سایت ارزان تبلیغات گوگل طراحی سایت صنعتی طراحی سایت آژانس مسافرتی بلیط هواپیما
I have their email addresses in a variable called bcc_list and the news flash in a variable called messagehtml.
I cannot send the update to them in one go, since I would like to include an unsubscribe link into the news flash e-mail.
As a consequence each e-mail must be personalised for the unsubscribe link and so I need to loop over the e-mail addresses.

Here's my code so far to achieve this:


Code: Select all
<cms:php>
   $emaillist=explode(',',<cms:show bcc_list />);
   foreach ($emaillist as $email) {
      <cms:send_mail to=$email from='me@example.com' subject="<cms:show messagesubject />" html='1'>
         <cms:show messagehtml />
         <...some code to generate the unsubscribe link and add it to the e-mail...>
      </cms:send_mail>
   }
</cms:php>





My problem is, how can I include the email address as stored in $email in the couch tag in the php code?

The code as shown above does not work. Also, first setting the email address with cms: set and then using it in send_mail using cms:show does not seem to work. Any ideas? All help appreciated!


thanks all
Hi :)

I see that you are using <cms:show bcc_list />, which suggests the 'bcc_list' is a Couch variable.
If that is correct, there is no need to use raw PHP for splitting and iterating through the items.
You may, for example, use the following instead -
Code: Select all
<cms:each bcc_list as='email' sep=','>
    <cms:show email /><br>
</cms:each>

You can then use the 'email' variable for further action e.g. to send the mails.

Hope this helps.
2 posts Page 1 of 1