I’m going to assume the folks receiving these emails has gone through the whole two step opt in procedure or they have given their consent in some other way.
There is an action called {$status}_{$post_type}
that fires whenever a post is transitioned from one status to another. So when a post is published, the hook publish_post
fires; when a custom post type is published the hook publish_the_custom_post_type
is fired.
You can hook into this, grab whatever post meta you need, and send emails.
Example:
<?php
// replace 'publish_post' with 'publish_your_post_type'
add_action('publish_post', 'wpse52135_transition', 10, 2);
/*
* When a post moves from 'draft' to 'publish, send an email
*
* @uses get_post_meta
* @uses update_post_mtea
* @uses wp_mail
*/
function wpse52135_transition($post_id, $post)
{
// store the fact that we sent an email in a custom field if that
// field is present, don't resend
if(get_post_meta($post_id, '_wpse52135_sent_mail', true))
return;
$email = get_post_meta($post_id, 'wpse52135_email', true);
// No email? bail.
if(!$email || !is_email($email)) return;
// email subject
$subject = sprintf(
__('New Post: %s', 'wpse52135'),
esc_attr(strip_tags($post->post_title))
);
// email body
$msg = sprintf(
__("Check out our new post: %s\n\n%s", 'wpse52135'),
esc_attr(strip_tags($post->post_title)),
get_permalink($post)
);
// send the email
wp_mail(
$email,
$subject,
$msg
);
update_post_meta($post_id, '_wpse52135_sent_mail', true);
}
As a plugin.