For a Project at work I had to implement a solution where [[Wordpress]] sends automated E Mails. In the end it was very easy but it was quite some digging trough the Codex to find what I needed, so I thought I share my work here.
All Magic happens in the functions.php file of your template, where else 😉
It all comes down to the wp_mail function
wp_mail($to, $subject, $message, $headers);
- $to – is the string or array with recipient E Mail addresses
- $subject – is the subject line
- $message – the E Mail body
- $header – is the an array for all E Mail Settings
everything pretty straight forward. The Headers array has some easy to use Settings:
- $headers = “Content-type: text/html”; – makes your E Mail an HTML Mail
- $headers = “From: The Sender <email@example.com>; – sets the Senders E Mail address
That’s all the Fun. Call that with any hook and your WordPress installation sends E Mails like magic (If you have a sendmail handler activated on your server but that’s another story).