我将使用Symfony2定期向许多用户发送简报.我要为那些在使用电子邮件客户端阅读时遇到问题的人提供HTML电子邮件的固定链接.
无论如何,假设我以这种方式发送简报:
// Assume success and create a new SentMessage to store and get permalink
$sent = new SentMessage();
$sent->setRecipients(/* ... */);
$sent->setSubject(/* ... */);
$sent->setContent(/* ... */);
// Get the slug for the new sent message
$slug = $sent->getSlug(); // Like latest-product-offers-546343
// Construct the full URL
// e.g. http://mydomain.com/newsletter/view/latest-product-offers-546343
// Actually send a new email
$mailer->send(/* .. */);
Run Code Online (Sandbox Code Playgroud)
如何构建完整的URL(域+控制器+动作+ slug)以将其包含在新电子邮件中?