Sending an email with headers via wp_mail

admin

Administrator
Staff member
I need to send mail from wordpress powered site. I am using wp_mail. I want to add $header to the mail so it would say who send it.

When i use $headers like that:

Code:
$headers = "From: $name <$email>"

$name and $email are propper variables*

And then

Code:
if (wp_mail( $to, $subject, $message, $headers) ) {
    echo 'Thanks!';
} else {
    echo 'Error!';

I always get "Error!" and no mail. I've read about 'wp_mail_from' and 'wp_mail_from_name' but I dont know how to use it.