2014-09-25 26 views
0

我在PHP中使用Swift_mailer发送自动生成的消息。最近我被要求扩展电子邮件以包含联系信息,所以我想在人们需要提供反馈时使用html'mailto'功能。我唯一无法弄清楚的是如何将主题从PHP/Swift_Mailer导入到HTML链接的主题中。目前的代码看起来像这样:Swift_Mailer import subject to'mailto:'HTML tag

<?php> 
.... 
$message->SetSubject("Subject"); 
.... 
<html> 
.... 
<a href="mailto:[email protected]?Subject%20to%20import%20subject%20here" target="_top">CLICK HERE</a> 

谢谢大家!

回答

0

这已无关Swiftmailer。你只是生成一个HTML链接。对于mailto,可以使用伪查询字符串:

<a href="mailto:[email protected]?subject=<?php echo url_encode($subject) ?>">...</a> 
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
1

从SwiftMailer源代码:

/** 
* A Message (RFC 2822) object. 
* 
* @package Swift 
* @subpackage Mime 
* @author  Chris Corbyn 
*/ 
interface Swift_Mime_Message extends Swift_Mime_MimeEntity 
{ 
    // [....] 
    /** 
    * Set the subject of the message. 
    * 
    * @param string $subject 
    */ 
    public function setSubject($subject); 

    /** 
    * Get the subject of the message. 
    * 
    * @return string 
    */ 
    public function getSubject();