PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Sep 23, 2017 8:35 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Aug 09, 2009 4:02 pm 
Offline
Forum Newbie

Joined: Wed Aug 13, 2008 2:48 pm
Posts: 13
How can I add a Reply-To header?

I am using SwiftMailer 3.3.

Syntax: [ Download ] [ Hide ]
<?php
 
require_once "Swift.php";
require_once "Swift/Connection/Sendmail.php";
$swift = new Swift(new Swift_Connection_Sendmail(Swift_Connection_Sendmail::AUTO_DETECT));
$mg = "This is the message\nHello123";
$message =& new Swift_Message('Subject Line');
$message->attach(new Swift_Message_Part($mg));
$swift->send($message, "example@gmail.com", new Swift_Address("example@gmail.com", "Example Sender"));
echo 'Sent!';
 
?>
 


Top
 Profile  
 
PostPosted: Mon Apr 08, 2013 5:02 pm 
Offline
Forum Newbie

Joined: Mon Apr 08, 2013 4:53 pm
Posts: 1
I created this account solely to reply to this message since it's currently ranking very high in search results for "swift mailer reply to header."

Here is the documentation: http://swiftmailer.org/docs/

In it, I could not find an example of adding a Reply-To header. So I used the source.

You are looking for this method: Swift_Mime_SimpleMessage::addReplyTo(). Swift_Message extends that class.

So, adding that to the code in the OP:

hknight wrote:
Syntax: [ Download ] [ Hide ]
<?php
 
require_once "Swift.php";
require_once "Swift/Connection/Sendmail.php";
$swift = new Swift(new Swift_Connection_Sendmail(Swift_Connection_Sendmail::AUTO_DETECT));
$mg = "This is the message\nHello123";
$message =& new Swift_Message('Subject Line');
$message->attach(new Swift_Message_Part($mg));

// HERE COMES THE REPLY-TO !!!
$message->addReplyTo('jdoe@example.com', 'John Doe');

$swift->send($message, "example@gmail.com", new Swift_Address("example@gmail.com", "Example Sender"));
echo 'Sent!';
 
?>
 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group