gdmaq_mail_to_queue()
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
gdmaq_mail_to_queue($args = array())
Description
This function adds a new email to the mail queue. A list of arguments contains the ‘type’ argument. This is usually detected by the plugin, but when passed by this function it can be anything. Check out this article for list of email types normally detected by the plugin:
Email types detected by the plugin
Extras array contains extra parameters from the PHPMailer class, and attachments are the array with attachments defined by the full path to the file. Headers array contains a list of headers, each one is defined as an array containing two values: the name of the header and value.
Parameters
- $args: array definition of the email to add to queue
Arguments
- to: one or more email addresses to send emails to.
- from: email of the email sender
- subject: email subject
- plain: plain text version of the email
- html: full HTML version of the email
- type: type of email, default: mail.
- headers: array with additional headers to include
- attachments: array with files to attach
- extras: array with additional parameters
If you want to send an email to more than one recipient, use the array for the ‘to’ value. Both ‘to’ and ‘from’ can be set to email only, but they can also contain name and email.
Example #1
Here is the basic example of adding an email into the queue.
gdmaq_mail_to_queue(array( 'to' => 'sendtoemail@example.com', 'subject' => 'This is just a test email', 'plain' => 'This is the email body...' ));
Example #2
Here is the example of adding an email into the queue for sending to 2 different emails. It also set’s from email.
gdmaq_mail_to_queue(array( 'to' => array( 'sendtoemail@example.com', array('secondemail@example.com', 'Example Name') ), 'from' => 'myemail@example.com, 'subject' => 'This is just a test email', 'plain' => 'This is the email body...' ));