9951 explained code solutions for 126 technologies


php-swiftmailerHow to get the message ID in SwiftMailer?


The message ID in SwiftMailer can be obtained by using the getId() method. This method returns a string containing the message ID.

Example code

$messageId = $message->getId();

Output example

<[email protected]>

Code explanation

  • $message: An instance of the Swift_Message class.
  • getId(): A method of the Swift_Message class which returns the message ID as a string.

Helpful links

Edit this code on GitHub