$swiftMessage->setSubject("Please confirm your Jpegery account"); /** * attach the content to the message * here, we set two versions of the message: the HTML formatted message and a special filter_var()ed * version of the message that generates a plain text version of the HTML content * notice one tactic used is to display the entire $confirmLink to plain text; this lets users * who aren't viewing HTML content in Emails still access your links **/ // building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account. $basePath = $_SERVER["SCRIPT_NAME"]; for ($i = 0; $i < 3; $i++) { $lastSlash = strrpos($basePath, "/"); $basePath = substr($basePath, 0, $lastSlash); } //Don't trust this one. $urlglue = $basePath . "/controllers/email-confirmation?profileVerify=" . $profile->getProfileVerify(); $confirmLink = "https://" . $_SERVER["SERVER_NAME"] . $urlglue; $message = <<<EOF <h1>Welcome to Jpegery!</h1> <p>Click the link to set up your password!</p> <a href="{$confirmLink}">{$confirmLink}</a></p> EOF; $swiftMessage->setBody($message, "text/html"); $swiftMessage->addPart(html_entity_decode(filter_var($message, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)), "text/plain"); /** * send the Email via SMTP; the SMTP server here is configured to relay everything upstream via CNM * this default may or may not be available on all web hosts; consult their documentation/support for details * SwiftMailer supports many different transport methods; SMTP was chosen because it's the most compatible and has the best error handling * @see http://swiftmailer.org/docs/sending.html Sending Messages - Documentation - SwitftMailer **/ $smtp = Swift_SmtpTransport::newInstance("localhost", 25);