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

Passing a URL in an email

Discussion in 'XenForo Development Discussions' started by tenants, Nov 1, 2012.

  1. tenants

    tenants Well-Known Member

    Hi, I'm creating a mod that sends a user an email

    Within this email, a url is sent:

    PHP:
    public function sendLoginKeyEmail(array $user$key)
        {
     
            
    $link XenForo_Link::buildPublicLink('full:login'$key, array('key' => $key));
                
    $mailParams = array(
                    
    'user' => $user,
                    
    'subject' => "login_security_link",
                    
    'boardTitle' => XenForo_Application::get('options')->boardTitle,
                    
    'message' =>
                    
    "Some one has tried to log in to your account from an ip address not associated to your Login Security \n".
             
                    
    "Sent from IP Address: \n".
             
                    
    "If this was you, you can log-in using this temporary link: \n".
                    
    "<a href='".$link."'>".$link."</a>"
             
                
    );
     
                
    $mail XenForo_Mail::create('contact'$mailParams0);
             
                
    $mail->send(
                    
    $user['email'], // $toEmail
                    
    $user['username'], // $toName
                    
    array(
                        
    'Sender' => XenForo_Application::get('options')->contactEmailAddress // $headers
                    
    ),
                    
    XenForo_Application::get('options')->contactEmailAddress,  // $fromEmail
                    
    XenForo_Application::get('options')->boardTitle// $fromName
                    
    XenForo_Application::get('options')->contactEmailAddress // $returnPath
                
    );
     
    The text is hard coded while I test it, they will be turned into phrases

    The question I have is that I wondered if anyone has managed to pass a URL as a link within an email using a similar method to the above. Right now, I'm finding the email message comes out as:

    If this was you, you can log-in using this temporary link:
    <a href='http:// someforum.co.uk/login/?key=24ca533bd47350925f5a6bac48ed9054d8f6d01abf7979a84'>http:// someforum.co.uk/login/?key=24ca533bd47350925f5a6bac48ed9054d8f6d01abf7979a84</a>

    It's not essential to have an active link, but it would be nice
     
  2. tenants

    tenants Well-Known Member

    Strange, if I use this:

    PHP:
    $mail XenForo_Mail::create('MAIL_CONTAINER'$mailParams0);
    this
    PHP:
    $mail XenForo_Mail::create('contact'$mailParams0);
    or this:
    PHP:
    $mail XenForo_Mail::create('conversation_insert_messagetext'$mailParams0);
    They all seem to get sent with the "contact" email template

    I've seen that the conversation template passes urls (and that the contact email sent doesn't) so I was hoping to piggy back the conversation templates... but alas, using the above, all get sent as contact templates... (The following message has been sent from user1 <mail> via the contact form at xxx.)

    Does anyone have experience with this?
     
  3. tenants

    tenants Well-Known Member

    I was being dumb, they do update and send the correct templates
    ... okay, now its just a matter of creating my own email template similar to the converstaion email templates (that seem to pass the url)...

    and then sending it with the method above...
     

Share This Page