I've been reading through the open issued and I saw some issues about exposing the API for managing subscriptions but I'm lookingo to creating newsletters from code.
I was trying to figure out insert_view and simplenews scheduler but I had some problems.
I will handle the views myself (I want to include some views conditionally) and I'll build the HTML I want to send. I couldn't figure out if there is an easy way to send this to all my subscribed users and take advantage of the throttling, per user plain text and unsubscribe features provided by simplenews.
I couldn't find any documentation on this, anyone attepted it before? The code of simplenews scheduler is a a little bit too complex as I don't need to save revisions or anything.
Any advice? Any thread about this? Is there an API for this purpose?
Thanks

Comments

sutharsan’s picture

Status: Active » Fixed

If you make your newsletter a node, assign it to simplenews, add a taxonomy term to it, you should be ready to go.

josepvalls’s picture

Status: Fixed » Active

Thanks for your reply.
What I understand is that my module will create a new node by code, assign it to simplenews and when I save it it will be sent. I may try it this way but I was wondering if there is a way to just send a message to the subscribers of a newsletter by code.
I'll be sending daily summaries of different sorts of site activity and I don't need to create all those nodes. I'd like the users to be able to subscribe and unsubscibe, use the throttling and so.

sutharsan’s picture

There is an issue in the queue to extract and abstract the subscription part out of simplenews. You are welcome to contribute. Simplenews is currently not build to send other content than newsletter nodes.

sapark’s picture

I think you could do this -- this is from simplenews_nodeapi() in simplenews.module

db_query("UPDATE {simplenews_newsletters} SET vid = %d, tid = %d, s_status = %d, s_format = '%s', priority = %d, receipt = %d
          WHERE nid = %d", $node->vid, $node->simplenews['tid'], SIMPLENEWS_STATUS_SEND_PENDING, $node->simplenews['s_format'], $node->simplenews['priority'], $node->simplenews['receipt'], $node->nid);
        // Send newsletter to all subscribers
      simplenews_send_node($node);

This sends the newsletter, with an onsreen message that says 'Newsletter Pending', and updates the management console to show 'Sent'. I think this might work, haven't tried it with lots of email addresses.

ragini’s picture

Hi,

I am unable to send mails using simplenews module. When I create Newsletter issue I am getting message called "Newsletter pending". Please can you help me to solve this issue.

sutharsan’s picture

ragini: wrong issue. Search the issue queue or create a new issue with more information.

sutharsan’s picture

Status: Active » Closed (fixed)

No activity, closing issue.

geerlingguy’s picture

Status: Closed (fixed) » Active

I, too, would like to simply be able to send batch daily, weekly, monthly, etc. emails out to sets of users, but without having to create a node for each newsletter (even if I had to create the node, have the email sent, then later delete the node after the emails are sent, that's a bit of overhead and clutter).

It would be awesome if there were a way to simply tell Simplenews to queue up a programmatically-created mail object, regardless of whether it's a node, or something else.

berdir’s picture

Category: support » feature
Priority: Normal » Minor

The new Simplenews Source concept is a start in this direction, abstracting the node however is still quite a bit of work.

We would need to completely abstract the simplenews_mail_spool through the SimplenewsSpoolInterface interface. This should actually be possible but won't be part of 7.x-1.x. You're welcome to work on it, though.

geerlingguy’s picture

(/me is no longer in need of such a feature, as I'm using queue API in D7 and Amazon SES to do batch emails now...).

But this would still be a killer feature; especially if things were abstracted enough to work with any kind of entity.