You should handle errors in your function the same way you handle them everywhere else.
However, as this is inside a function, you need to make the connection available in the scope of the function.
There are several ways to do that, some examples (from not that good to better...):
- declare your PDO connection variable global in your function. I would not recommend this as a final solution, but it would work while you improve on things;
- add the PDO connection as an additional parameter to your function. Although better than 1., you would need to change all function calls to include the new parameter(s);
- refactor to OOP and use dependency injection to add your PDO connection to your email class / object.