0

I'm using Swift_mailer in PHP to send auto generated messages. I've recently been asked to expand the e-mail to include contact information, so I want to use the html 'mailto' function for when people need to provide feedback. The only thing I can't figure out is how to import the subject from the PHP/Swift_Mailer into the subject in the HTML link. Current code looks something like this:

<?php>
....
$message->SetSubject("Subject");
....
<html>
....
<a href="mailto:someone@somewhere.com?Subject%20to%20import%20subject%20here" target="_top">CLICK HERE</a>

Thanks all!

I Dabble
  • 321
  • 2
  • 11

2 Answers2

1

From SwiftMailer source code:

/**
 * 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();
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
0

That has nothing to do with Swiftmailer. You're just generating an HTML link. For mailto, you can use a pseudo-query string:

<a href="mailto:someone@example.com?subject=<?php echo url_encode($subject) ?>">...</a>
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Marc B
  • 356,200
  • 43
  • 426
  • 500