Problem using wp_mail function in WPMU

I added this line to my wpmu-functions.php file at the end of the newuser_notify_siteadmin function

$headers = 'From: Calvin Micklefinger <calvinmicklefinger@hotmail.com>' . "\r\n\\";
   wp_mail('kirk@mydomain.com', 'subject', 'message', $headers);

I would have expected that as simple as that is, the email "From" would have said

Calvin Micklefinger <calvinmicklefinger@hotmail.com>

As limited as my coding skills are, I really don't see much choice for any other response.

What I got was

"accountingpractitioner.com" <calvinmicklefinger@hotmail.com>

Why in the Sam Hill is that happening? Where do I look to find a solution? This is also disrupting a very solid and well respected plugin I use.

    Aaron

    Did you try just using a plugin to filter the from name/email?

    Kirk Ward

    Not sure what you mean or what a filter would accomplish.

    My goal is to send an email to my autoresponder to subscribe the new user to a campaign series as soon as their blog is activated.

    No one has been able to suggest a method.so I am trying to learn and I figured the best place to do it would be to do it at the same time as the admin notifications are sent.

    Tried copying that notification and duplicating it, but I didn't get a second email. At least using this I got an email.

    Got any suggestions?

    Aaron

    You can do it via plugin tying into the 'wpmu_new_blog' action. Though you will have to figure out the wp_mail header issue still at least you won't be modifying core files. There is an example in the antisplog plugin.

    Kirk Ward

    While waiting for my hosting company to respond, I did a bunch of Googling ... not knowing what the words meant. I kept running across the word filter, wp_mail_from and wp_mail_from_name

    In that confusion, I wound up looking at stuff I did not understand, but wound up in the midst of pluggable.php and reading a thread at http://core.trac.wordpress.org/ticket/12851 which discussed the filter in pluggable.

    Can you explain those things to me and if they are causing the name to be changed?

    Cheers and Cheerios

    Aaron

    tie into the filters does that not work?

    Kirk Ward

    I have no clue how to tie into filters or what that even means.

    Clue?

    Kirk Ward

    http://codex.wordpress.org/Plugin_API#Filters

    Aaron, old buddy, old pal, can you say "That's all Greek to me"? I am still totally lost. Guess it's time to shell out money to correct what appears to be a WPMU feature (or bug). Money which I doesn't got. That's so sad. Sob.

    Kirk Ward

    @joshmac - I had been looking for that plugin to try. I will report back as yea or nay.

    Kirk Ward

    @joshmac - Thanks, but it only allows an admin to set the defaults. What I need is for WPMU to allow emails to be sent with the "from" address formatted to identify the actuall submitter.

    Think of an application such as a "Contact Form," or one of those spammy "Tell A Friend" applications where the email goes out with the name entered into the submission form.

    Kirk Ward

    http://codex.wordpress.org/Function_Reference/wp_mail

    Hi Aaron,

    That post is where I found the code I used in my original post to this thread.

    I have looked at the anti-splog.php file and tried to understand it. There are two instances of wp_mail, and I do not understand them beyond the code I used in the original post. I used the second one as my model when I copied the code from the coex post.

    I don't want to waste any more of your time on a singular need (mine alone). Best I find a coder who knows how to do stuff ... I sure don't feel qualified to even follow instructions.

    Oh what a poor lost soul. Wailey, wailey, wailey.

    Kirk Ward

    Solution found.

    Use mail() instead of wp_mail()

    Kirk Ward

    This all got started because if a contact form I was trying to use. I had not been able to get one to work as well as the "Fast and Secure Contact Form" by Mike Challis. However, I wanted the email to identify the sender in the "from" portion of the header and the WPMU filters were blocking this.

    Last night I advised Mike of the WP Trac regarding this issue and he modified his code to include filters to handle the wp_mail problem. While it is specific to his implementation, I am including some of the code he changed in the hope it will benefit others.

    $header = '';
          // prepare the email header
          if ($ctf_email_on_this_domain != '') {
             // $header =  "From: $ctf_email_on_this_domain" . PHP_EOL;
             $this->si_contact_mail_from = $ctf_email_on_this_domain;
             add_filter( 'wp_mail_from', array(&$this,'si_contact_form_mail_from'));
          } else {
             // $header = "From: $name <$email>" . PHP_EOL;
             $this->si_contact_mail_from = $email;
             $this->si_contact_from_name = $name;
             add_filter( 'wp_mail_from', array(&$this,'si_contact_form_mail_from'));
             add_filter( 'wp_mail_from_name',
    array(&$this,'si_contact_form_from_name'));
          }
    
    function si_contact_form_mail_from() {
     return $this->si_contact_mail_from;
    }
    
    function si_contact_form_from_name() {
     return $this->si_contact_from_name;
    }
    Chris
    • Elite
    • 286
    • #325

    I'm having a similar conflict with a contact form (Contact Form 7). Where would I add the above code?

Join 370724 happy members

Get access to our entire collection of epic plugins, astonishing themes & genius support

Become a member