Forums

[resolved] wp_mail: Change sender e-mail to post or comment author's e-mail? (3 posts)

  1. fireundubh
    Member
    Posted 5 years ago #

    I've been trying to modify wp_mail()'s sender e-mail address to the post or comment author's e-mail address for awhile.

    Anyone know how this can be done?

    function wp_mail($to, $subject, $message, $headers = '') {

    if( $headers == '' ) {

    $from = get_userdata($post->post_author);

    $headers = "MIME-Version: 1.0\n" .
    "From: ". $from->user_email ."\n" .
    "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";

    }

    return @mail($to, $subject, $message, $headers);

    }

  2. fireundubh
    Member
    Posted 5 years ago #

    Found an alternate solution. Nevermind.

  3. pulk
    Member
    Posted 5 years ago #

    then why don't share it with the whole world?

Topic Closed

This topic has been closed to new replies.

About this Topic