Conditional wp_mail statement on post

Here are a couple of things:

  1. You’re mixing ‘ and ” in a very bad way!
  2. You’re echoing inside a string. Don’t do that.
  3. You’re silencing any errors on the wp_mail function, so if WordPress is giving you an error you’ll never see it!

First, fix your ‘ and ” problem. Your $subject definition should read like this:

$subject = "New Ticket in " . get_post_meta($pid, 'problem_type', true);

This fix also fixes the echo problem.

Next, remove the @ from in front of wp_mail and turn on WP_DEBUG in your config files so you can see any errors that crop up.