What is the purpose of using setReplyTo in SwiftMailer for email sending in PHP?
When sending emails using SwiftMailer in PHP, the setReplyTo method allows you to specify a different email address for recipients to reply to instead of the sender's email address. This can be useful when you want replies to be directed to a different department or individual within your organization.
// Create the Transport
$transport = new Swift_SmtpTransport('localhost', 25);
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
// Create a message
$message = new Swift_Message('Subject of Your Email');
$message->setFrom(['your@email.com' => 'Your Name']);
$message->setTo(['recipient1@email.com', 'recipient2@email.com']);
$message->setBody('This is the body of your email.');
// Set the reply-to address
$message->setReplyTo('replyto@email.com');
// Send the message
$result = $mailer->send($message);
Keywords
Related Questions
- How can database structure differences between two PHPBB forums be addressed during the merging process to prevent data loss?
- What potential pitfalls should be considered when using PHP to interact with a database for dropdown menu functionality?
- How can storing navigation rubrics in an array or session variable improve performance in a PHP application?