• So I’ve got a problem with wp_mail sending from the wrong e-mail address. I want it to come from a specific user in this case. My code to get the user’s e-mail works, because it echoes properly in the $message section.

    The problem seems to be my formatting of the concatenation on the $headers section. Here’s my mail codes I’ve tried, to no avail. This first one was from another stackoverflow post.

    $headers = "From:" . apply_filters( 'wp_mail_from',$fromEmail);
    wp_mail($to, $subject, $message, $headers);

    $headers = "From:" . $fromEmail;
    wp_mail($to, $subject, $message, $headers);

    $headers = "From: ".$fromEmail."\r\n";
    wp_mail($to, $subject, $message, $headers);

    I’m ripping my hair out. I have another wp_mail form elsewhere in the site that inputs the $headers variables using the $_POST method, but I’m not using that to get the data. And again, the e-mail echoes in the $message section. So I’m going insane trying to figure out why it’s not working.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    What does $fromEmail resolve to? The Codex page offers this example:
    $headers = 'From: My Name <[email protected]>' . "\r\n";

    I don’t know if “My Name” is really required, but I suspect the angle brackets are important, try adding them to your email address. If that doesn’t help, maybe you really do need a My Name string.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_mail “from” header concatenation trouble’ is closed to new replies.