{"id":32613859,"url":"https://github.com/rezozero/subscribeme","last_synced_at":"2025-10-30T15:55:11.933Z","repository":{"id":62535351,"uuid":"183012523","full_name":"rezozero/subscribeme","owner":"rezozero","description":"Simple mailing-list subscriber factory.","archived":false,"fork":false,"pushed_at":"2025-06-26T10:39:31.000Z","size":91,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-05T06:22:44.658Z","etag":null,"topics":["email","mailing-list","mailjet-api"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rezozero.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-23T12:41:32.000Z","updated_at":"2025-06-26T10:38:06.000Z","dependencies_parsed_at":"2025-06-26T10:34:50.980Z","dependency_job_id":null,"html_url":"https://github.com/rezozero/subscribeme","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/rezozero/subscribeme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezozero%2Fsubscribeme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezozero%2Fsubscribeme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezozero%2Fsubscribeme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezozero%2Fsubscribeme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rezozero","download_url":"https://codeload.github.com/rezozero/subscribeme/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezozero%2Fsubscribeme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281835582,"owners_count":26569857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","mailing-list","mailjet-api"],"created_at":"2025-10-30T15:55:00.801Z","updated_at":"2025-10-30T15:55:11.923Z","avatar_url":"https://github.com/rezozero.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Subscribe me\n\n[![Static analysis and code style](https://github.com/rezozero/subscribeme/actions/workflows/run-test.yml/badge.svg)](https://github.com/rezozero/subscribeme/actions/workflows/run-test.yml)\n\nUnified Email Service Library: A simple mailing list subscriber factory that includes a mailing list subscription feature and the ability to send transactional emails.\n\n## Supported platforms\n\n- Mailjet\n- Mailchimp (use Mandrill for transactional emails)\n- Brevo (ex SendInBlue)\n- Brevo DOI (Double Opt-In) (ex SendInBlue)\n- YMLP\n\n## Usage\n\n```\ncomposer require rezozero/subscribeme\n```\n\n```php\nuse SubscribeMe\\Factory;\n\n/**\n* This library uses PSR18 and PSR17 so you need to provide a client that implements PSR18 like Guzzle for example\n * @param ClientInterface $client\n * @param RequestFactoryInterface $requestFactory\n * @param StreamFactoryInterface $streamFactory\n*/\n$factory = new Factory($client, $requestFactory, $streamFactory);\n\n// ######## GUZZLE EXAMPLE ##########\n$client = new \\GuzzleHttp\\Client();\n$httpFactory = new GuzzleHttp\\Psr7\\HttpFactory();\n$factory = new Factory($client, $httpFactory, $httpFactory);\n// ##################################\n\n// 'mailjet' | 'brevo' | 'mailchimp' | 'ymlp'\n$subscriber = $factory-\u003ecreateFor('mailjet');\n\n$subscriber-\u003esetApiKey('xxxx');\n$subscriber-\u003esetApiSecret('xxxx');\n$subscriber-\u003esetContactListId('xxxx');\n\n$userConsent = new \\SubscribeMe\\GDPR\\UserConsent();\n$userConsent-\u003esetReferrerUrl('https://form.test');\n$userConsent-\u003esetReferrerFieldName('gdpr_consent_referrer');\n$userConsent-\u003esetConsentGiven(true);\n$userConsent-\u003esetConsentFieldName('gdpr_consent');\n$userConsent-\u003esetIpAddress('xx.xx.xx.xx');\n$userConsent-\u003esetIpAddressFieldName('gdpr_consent_ip_address');\n$userConsent-\u003esetConsentDate(new \\DateTime());\n$userConsent-\u003esetDateFieldName('gdpr_consent_date');\n$userConsent-\u003esetUsage('E-mail marketing campaigns');\n$userConsent-\u003esetUsageFieldName('gdpr_consent_usage');\n\n$subscriber-\u003esubscribe('hello@super.test', ['Name' =\u003e 'John Doe'], [$userConsent]);\n\n/**\n * Method for sending transactional emails (YMLP does not support transactional emails).\n *\n * @param array\u003c\\SubscribeMe\\ValueObject\\EmailAddress\u003e $emails (email required, name optional)\n * @param int|string $emailTemplateId required\n * @param array $variables optional\n */\n$subscriber-\u003esendTransactionalEmail($emails, $emailTemplateId, $variables)\n```\n\n### Symfony usage\n\nWith Symfony, you don't have to use the `Factory`,\nyou can directly make your code generic by depending on `SubscriberInterface`,\nwhich means that if you want to change platform later,\nyou will just have to change the registration.\n\n```php\nfinal class YourClass\n{\n    public function __construct(\n        // Make it generic, let Symfony provide the right service for you\n        private SubscriberInterface $subscriber\n    ) {\n    }\n    \n    public function sendTransactional()\n    {\n        $this-\u003esubscriber-\u003esendTransactionalEmail(\n            [\n                new EmailAddress('user@example.com')\n            ],\n            $templateId\n        )\n    }\n}\n```\n\n```yaml\n# services.yaml\nservices:\n  SubscribeMe\\Subscriber\\SubscriberInterface:\n    # Here register the platform class used in your project (example with Mailjet)\n    class: SubscribeMe\\Subscriber\\MailjetSubscriber\n    # Here comes the Symfony magic, PSR17 and PSR18 will be automatically provided\n    autowire: true\n    calls:\n      # Here call necessary methods according to your platform (Mailjet need apiKey and apiSecret)\n      - setApiKey: [ '%env(string:APP_MAILJET_API_KEY)%' ]\n      - setApiSecret: [ '%env(string:APP_MAILJET_API_SECRET_KEY)%' ]\n```\n\n## GDPR consent support\n\nPrepare your audience list with additional fields in order to store your users consent (https://www.mailjet.com/gdpr/consent/) :\n\n```php\n$userConsent = new \\SubscribeMe\\GDPR\\UserConsent();\n\n$userConsent-\u003esetReferrerUrl('https://form.test');\n$userConsent-\u003esetReferrerFieldName('gdpr_consent_referrer');\n\n$userConsent-\u003esetConsentGiven(true);\n$userConsent-\u003esetConsentFieldName('gdpr_consent');\n\n$userConsent-\u003esetIpAddress('xx.xx.xx.xx');\n$userConsent-\u003esetIpAddressFieldName('gdpr_consent_ip_address');\n\n$userConsent-\u003esetConsentDate(new \\DateTime());\n$userConsent-\u003esetDateFieldName('gdpr_consent_date');\n\n$userConsent-\u003esetUsage('E-mail marketing campaigns');\n$userConsent-\u003esetUsageFieldName('gdpr_consent_usage');\n```\n\nSome platform already have special mechanism for GDPR consent such as *Mailchimp* : \n\n```php\n$userConsent = new \\SubscribeMe\\GDPR\\UserConsent();\n\n$userConsent-\u003esetConsentGiven(true);\n// Find your Mailchimp marketing permission ID \n// with a single API call on some existing contacts\n$userConsent-\u003esetConsentFieldName('e7443e1720');\n\n$userConsent-\u003esetIpAddress('xx.xx.xx.xx');\n```\n\nYou can add multiple `UserConsent` objects when platform allows it.\n\n```php\n$userConsentEmail = new \\SubscribeMe\\GDPR\\UserConsent();\n$userConsentEmail-\u003esetConsentGiven(true);\n$userConsentEmail-\u003esetConsentFieldName('e7443e1720');\n$userConsentEmail-\u003esetIpAddress('xx.xx.xx.xx');\n\n$userConsentAds = new \\SubscribeMe\\GDPR\\UserConsent();\n$userConsentAds-\u003esetConsentGiven(false);\n$userConsentAds-\u003esetConsentFieldName('other_marketing_id');\n$userConsentAds-\u003esetIpAddress('xx.xx.xx.xx');\n\n$subscriber = $factory-\u003ecreateFor('mailchimp');\n$subscriber-\u003esubscribe(\n    'hello@super.test', \n    ['FNAME'=\u003e'Hello', 'LNAME'=\u003e'Super'],\n    [$userConsentEmail, $userConsentAds]\n);\n```\n\n## Mailchimp\n\n### Mailchimp options subscriber\n\n```php\n$subscriber = $factory-\u003ecreateFor('mailchimp');\n$subscriber-\u003esetApiKey('your_api_key');\n$subscriber-\u003esetContactListId('xxxx');\n// Set you account datacenter\n$subscriber-\u003esetDc('us19');\n// Choose which status your new user will be given\n$subscriber-\u003esetSubscribed();\n// or\n$subscriber-\u003esetPending();\n```\n\n### Mailchimp options sender transactional email\n\nMailchimp use Mandrill api for his transactional emails\nSee https://mailchimp.com/developer/transactional/api/messages/send-using-message-template/\n\n```php\n$subscriber = $factory-\u003ecreateFor('mailchimp');\n// Mailchimp only requires an API Key\n$subscriber-\u003esetApiKey('mailchimp_api_key');\n// use an array of value object EmailAddress for recipients\n$emails = [\n    new \\SubscribeMe\\ValueObject\\EmailAddress('hello@super.test', 'John Doe')\n];\n// Mailchimp only use string for his $templateEmailId\n$emailTemplateId = 'template_name';\n/** \n * MailChimp accepts an array of variables to inject into your transactional template.\n*/\n$variables = [\n    'FNAME' =\u003e 'John',\n    'LNAME' =\u003e 'Doe'\n];\n$subscriber-\u003esendTransactionalEmail($emails, $emailTemplateId, $variables);\n```\n\n### Mailchimp options unsubscribing\n\nMailchimp does not support unsubscribing a user from a list with their email address, we throw an `UnsupportedUnsubscribePlatformException`.\n\n## YMLP\n\n### YMLP options subscriber\n\nSee https://www.ymlp.com/app/api_command.php?command=Contacts.Add\n\n```php\n$subscriber = $factory-\u003ecreateFor('ymlp');\n$subscriber-\u003esetApiKey('your_username');\n$subscriber-\u003esetApiSecret('your_api_key');\n$subscriber-\u003esetContactListId('your_group_id');\n// if true the email address will be added even if this person previously \n// unsubscribed or if the email address previously was removed by bounce back handling\n$subscriber-\u003esetOverruleUnsubscribedBounced(true);\n```\n\nFor getting your additional fields ID: see https://www.ymlp.com/api/Fields.GetList?Key=api_key\u0026Username=username\n\n### YMLP options sender transactional email\n\nYMLP does not support transactional email, we throw an `UnsupportedTransactionalEmailPlatformException`.\n\n### YMLP options unsubscribing\n\nYMLP does not support unsubscribing a user from a list with their email address, we throw an `UnsupportedUnsubscribePlatformException`.\n\n## Brevo\n\n### Brevo subscriber options\n\nSee https://developers.brevo.com/reference#createcontact\n\n```php\n$subscriber = $factory-\u003ecreateFor('brevo');\n// Brevo only requires an API Key\n$subscriber-\u003esetApiKey('brevo_api_key');\n// Brevo list identifiers are int. You can subscribe user to multiple lists with comma-separated list \n$subscriber-\u003esetContactListId('3,5,3'); \n\n$subscriber-\u003esubscribe('hello@super.test', [\"FNAME\" =\u003e \"Elly\", \"LNAME\" =\u003e \"Roger\"], [$userConsent]);\n```\n\nFor getting your additional fields ID: see https://my.brevo.com/lists/add-attributes\n\n### Brevo Double Opt-In options\n\nSee https://developers.brevo.com/reference/createdoicontact\n\n```php\n$subscriber = $factory-\u003ecreateFor('brevo-doi');\n// Brevo only requires an API Key\n$subscriber-\u003esetApiKey('brevo_api_key');\n// Brevo list identifiers are int. You can subscribe user to multiple lists with comma-separated list \n$subscriber-\u003esetContactListId('3,5,3'); \n$subscriber-\u003esetTemplateId(1); \n$subscriber-\u003esetRedirectionUrl('https://www.example.com/subscribed');  \n\n$subscriber-\u003esubscribe('hello@super.test', [\"FNAME\" =\u003e \"Elly\", \"LNAME\" =\u003e \"Roger\"], [$userConsent]);\n```\n\n### Brevo sender transactional email options\n\nSee https://developers.brevo.com/reference/sendtransacemail\n\n```php\n$subscriber = $factory-\u003ecreateFor('brevo');\n// Brevo only requires an API Key\n$subscriber-\u003esetApiKey('brevo_api_key');\n// use an array of value object EmailAddress for recipients\n$emails = [\n    new EmailAddress('jimmy98@example.com', 'Jimmy');\n]\n// Brevo only use int for his $templateEmailId\n$templateEmail = 1;\n/** \n * Brevo accepts an array of variables to inject into your transactional template.\n*/\n$variables = [\n    'FNAME' =\u003e 'Joe',\n    'LNAME' =\u003e 'Doe'\n];\n$subscriber-\u003esendTransactionalEmail($emails, $templateEmail, $variables);\n```\n\n### Brevo options unsubscribing\n\nSee https://developers.brevo.com/reference/removecontactfromlist\n\n```php\n$subscriber = $factory-\u003ecreateFor('brevo');\n// Brevo only requires an API Key\n$subscriber-\u003esetApiKey('brevo_api_key');\n// Use Just One list Id in same time for remove contact from a list\n$subscriber-\u003esetContactListId('3'); \n$subscriber-\u003eunsubscribe('jimmy98@example.com');\n```\n\n## Mailjet\n\n### Mailjet subscriber options\n\n```php\n$subscriber = $factory-\u003ecreateFor('mailjet');\n// Mailjet requires an API Key and an API Secret\n$subscriber-\u003esetApiKey('mailjet_api_key');\n$subscriber-\u003esetApiSecret('mailjet_api_secret')\n// Mailjet list identifiers are int. You can subscribe user to multiple lists with comma-separated list \n$subscriber-\u003esetContactListId('3,5,3');\n\n$subscriber-\u003esubscribe('hello@super.test', [\"FNAME\" =\u003e \"Elly\", \"LNAME\" =\u003e \"Roger\"], [$userConsent]);\n```\n\n### Mailjet sender transactional email options\n\nSee https://dev.mailjet.com/email/guides/send-api-v31/#use-templating-language\n\n```php\n$subscriber = $factory-\u003ecreateFor('mailjet');\n// Mailjet requires an API Key and an API Secret\n$subscriber-\u003esetApiKey('mailjet_api_key');\n$subscriber-\u003esetApiSecret('mailjet_api_secret')\n// use an array of value object EmailAddress for recipients\n$emails[] = new EmailAddress('passenger1@mailjet.com', 'passenger 1');\n// Mailjet only use int for his $templateEmailId\n$templateEmail = 1;\n/** \n * Mailjet accepts an array of variables to inject into your transactional template.\n*/\n$variables = [\n    'day' =\u003e 'Tuesday',\n    'personalmessage' =\u003e 'Happy birthday!'\n];\n$subscriber-\u003esendTransactionalEmail($emails, $templateEmail, $variables);\n```\n\n### MailJet options unsubscribing\n\nMailJet does not support unsubscribing a user from a list with their email address, we throw an `UnsupportedUnsubscribePlatformException`.\n\n\n## OxiMailing\n\n### OxiMailing subscriber options\n\n```php\n$subscriber = $factory-\u003ecreateFor('oximailing');\n// OxiMailing requires an API Key and an API Secret\n$subscriber-\u003esetApiKey('oximailing_api_key');\n$subscriber-\u003esetApiSecret('oximailing_api_secret')\n// OxiMailing list identifiers are int. You can only subscribe user to one list\n$subscriber-\u003esetContactListId('123');\n// OxiMailing Accept 3 modes\n//Allows you to explain what to do with new duplicates :\n//- ignore : remove duplicates\n//- insert : don't do anything (all contacts are imported even duplicates)\n//- update : update existing contacts information rather than adding duplicates\n// Defaults to mode: ignore\n$subscriber-\u003esubscribe('hello@super.test');\n// You can override subscription mode using options array\n$subscriber-\u003esubscribe('hello@super.test', ['mode' =\u003e 'update']);\n```\n\n### OxiMailing sender transactional email options\n\nOxiMailing does not support transactional email, we throw an `UnsupportedTransactionalEmailPlatformException`.\n\n### OxiMailing options unsubscribing\n\nSee https://api.oximailing.com/doc/#/contacts/delete_lists__ListId__contacts\n\n```php\n$subscriber = $factory-\u003ecreateFor('oximailing');\n// OxiMailing requires an API Key and an API Secret\n$subscriber-\u003esetApiKey('oximailing_api_key');\n$subscriber-\u003esetApiSecret('oximailing_api_secret')\n// You can only unsubscribe one user to one list\n$subscriber-\u003esetContactListId('123');\n$subscriber-\u003eunsubscribe('jimmy98@example.com');\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezozero%2Fsubscribeme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezozero%2Fsubscribeme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezozero%2Fsubscribeme/lists"}