We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8942
    • 12 Posts
    I’m sure I’m not the first to ask this question, but several searches have come up empty, so maybe I’m the first to ask it in this way. smiley

    We have a lot of events that people want to invite others to. Personally I’m taking my daughters to this one (http://www.nsb.org/news/upcoming-events/2009/10/daddy-daughter-dessert) and thought it would be cool to "email this page" to my wife to let her know about the date and time. Of course being a tech it’s pretty easy for me to copy and paste it into an email, but we have a large quantity of low-tech people that have trouble with that kind of thing.

    Any suggestions?
      • 15083
      • 697 Posts
      Hi there,

      This would be a simple snippet, to send the url via email...
      Something like (please note probably has errors and would need validation!!):

      <?php
      
      (isset($id)) ? $id : $id = $modx->documentIdentifier;
      $pagelink = $modx->makeurl($id);
      
      // To send HTML mail, the Content-type header must be set
      $headers  = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      
      $fromaddress = '[email protected]';
      $to = $_POST['your_friends_email_from_your _form'];
      $subject = 'Your friend wants you to see this page!';
      	
      // Additional headers
      $headers .= 'From: '.$fromaddress. "\r\n";
      $message = '<p>Please <a href="'.$pagelink.'">Click here</a> to view content.</p>';
      
      // Send...
      if (mail($to, $subject, $message, $headers)) 
      { 
        return 'Page sent...';
      } else
      {
        return 'opps!!!';
      }
      
      ?>
        • 8942
        • 12 Posts
        Oh wow, that’s more than I was expecting. I’ll try this out and let you know how it works. I’ll also post the final code (I have a little PHP experience, so if it needs some tweaking I should be able to figure it out). Thank you SO much.