Custom script using our code
This documentation shows you examples of PHP code you can use to perform actions in AcyMailing
Before using our code
Making sure your CMS is loaded
If you want to use the AcyMailing code outside of your site, you will need to load your site's library then the AcyMailing library.
Add these lines first in your script and don't forget to replace PATH_TO_YOUR_JOOMLA_SITE_ROOT_FOLDER by the real value
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', 'PATH_TO_YOUR_JOOMLA_SITE_ROOT_FOLDER');
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
$app = JFactory::getApplication('site');Add these lines first in your script and don't forget to replace PATH_TO_YOUR_JOOMLA_SITE_ROOT_FOLDER by the real value
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', 'PATH_TO_YOUR_JOOMLA_SITE_ROOT_FOLDER');
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
$container = \Joomla\CMS\Factory::getContainer();
$container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');
$app = $container->get(\Joomla\CMS\Application\SiteApplication::class);Add these lines first in your script and don't forget to replace PATH_TO_YOUR_JOOMLA_SITE_ROOT_FOLDER by the real value, and to change $context if needed.
Add these lines first in your script and don't forget to replace PATH_TO_YOUR_WORDPRESS_SITE_ROOT_FOLDER by the real value
Load the AcyMailing library
Before each of the following examples, please make sure the AcyMailing library is loaded.
Subscribers
Create a new subscriber
Get a subscriber and / or its subscriptions
Lists
Create a list
Get the lists
Delete a list
Subscriptions
Subscribe or remove a user from one or several lists
Campaigns
Create a campaign
Sending a campaign to its lists
Sending emails
Insert an e-mail in the queue
Send an email to a single user
Sometimes you want to send a pre-saved email to a single user only... In that case you should not bother with the queue system and use this code (it will send the email ID 67 to the user "[email protected]"):
The email ID can be found in the xxxx_acym_mail table, this is NOT the campaign ID displayed on the campaigns listing
Last updated