1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

$mail->send ignores $fromEmail (bug?)

Discussion in 'XenForo Development Discussions' started by Chris D, Aug 29, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    Ok, so I have an add-on which sends an e-mail.

    Overall, this is working perfectly. The e-mail is sent using the correct template, it is sent to the right person, it is sent from the default name and e-mail address for the board.

    It is the latter I would like to change.

    So... I have:

    PHP:
    $options XenForo_Application::get('options');
    $fromEmail $options->fromEmail;
    $mail = new XenForo_Mail('my_email_template'$params$visitor['language_id']);
    $mail->send($toEmail$toName$headers = array(), $fromEmail);
    If I echo $fromEmail then the correct address as defined in Admin CP options is returned, yet when the e-mail is sent the from email address is simply the board default.

    This could well be a bug - if it is feel free to move it to Bug Reports - though probably more likely is I've missed something :unsure:

    Thanks guys (y)
     
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    okay... I just checked XF's Mail class I couldn't find any error in the code... XF will use it's default mail if the $fromEmail var is empty... :rolleyes:
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    So this looks like a bug then?
     
  4. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    maybe... this is the piece of code that handles the function:
    PHP:
    if ($fromEmail)
    {
        
    $mailObj->setFrom($fromEmail$fromName);
    }
    else
    {
        
    $mailObj->setFrom($options->defaultEmailAddress$fromName);
    }
    try 'expanding' the base class?
     

Share This Page