Is it possible to send emails programmatically to a PHPList list?

1.2k views Asked by At

I am looking for a solution to send automated emails from my website to PHPList lists. From my understanding, PHPList's emails are authored manually using the web-based interface provided by the application. Are there some APIs I can use to allow my website to send emails directly?

3

There are 3 answers

2
kscorrales On

first, if is a list of emails, yo need use queues, you only need have the emails stored in a database, and then sending through queues with a cicle of the emails of the database

2
Henry On

You can just code one like this, just need to change some of the values on the insert strings to match your list. So when someone creates and account on your website, you just call a routine like this and insert it into PHPLIST.

You can also do it with a trigger on your members table. The code below is VB.NET - but you can easily convert it to php.

 Public Sub AddMemberToPHPList(ByVal vUserEmail As String)

    Dim moConn As MySqlConnection
    moConn = New MySqlConnection("server=*********;User Id=******;Password=*******;Persist Security Info=True;database=phplist;Ssl Mode=None;Allow User Variables=True;")
    moConn.Open()

        Dim oMySqlCommand As New MySqlCommand
        oMySqlCommand.Connection = moConn
        oMySqlCommand.Parameters.AddWithValue("email_address", vUserEmail.ToLower)
        oMySqlCommand.Parameters.AddWithValue("uniqid", Guid.NewGuid)
        oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_user_user set email = ?email_address, confirmed=1,entered = now(),modified = now(),uniqid = ?uniqid,htmlemail = 1, bouncecount=0,disabled = 0"
        oMySqlCommand.CommandType = CommandType.Text
        oMySqlCommand.ExecuteNonQuery()
        oMySqlCommand.CommandText = "INSERT IGNORE INTO phplist_listuser set userid = (select id from phplist_user_user where email = ?email_address) , listid = 3, entered = now(), modified= now()"
        oMySqlCommand.ExecuteNonQuery()


End Sub
0
Cronk On

This reply is rather late I realize, but I think you'd do well to look into this plugin for PHPList:
https://resources.phplist.com/plugin/submitbymail

The plugin page says that the author is no longer supporting/developing the plugin, but the code that is there should work on current versions of PHPList.

I used to use an older plugin (called 'MailToList') for this exact purpose - someone can compose an email somewhere else, send it to a specific address on their system, and then the plugin watches those email inboxes for new emails and will queue up a new 'campaign' using that email as the source. So you essentially have to set up one email inbox for each list you want to send out to in PHPList.

(I'm just going through an upgrade process on my PHPList system and will probably use this 'SubmitByMail' plugin since the 'MailToList' plugin appears to not exist any more. But I haven't yet actually used the 'SubmitByMail' plugin.)