嗯,我想这是可行的:
注意:我正在使用Postman SMTP; 对于下面的示例,我认为您必须为每个“发件人”电子邮件正确配置服务器/事务性电子邮件传递服务
function conditional_multisite_wp_mail( $post_id, $post, $update ) {
$to1 = \'[email protected]\';
$to2 = \'[email protected]\';
$subject1 = \'SPECIFIC: testing right meow\';
$subject2 = \'CURRENT: testing right meow\';
$message = \'woof\';
$headers1 = \'From: Derp < [email protected] > \\r\\n\';
$headers2 = \'From: Herp < [email protected] > \\r\\n\';
switch_to_blog(1); // Switch to specific site
wp_mail( $to1, $subject1, $message, $headers1, $attachments );
restore_current_blog(); // Restore to current site
wp_mail( $to2, $subject2, $message, $headers2, $attachments );
}
add_action( \'save_post\', \'conditional_multisite_wp_mail\', 10, 3 );