Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:43:56+00:00 2026-06-11T07:43:56+00:00

I use SwiftMailer in my PHP scripts to send emails and I use TinyMCE

  • 0

I use SwiftMailer in my PHP scripts to send emails and I use TinyMCE as a text editor to write and format the message body. The problem is that when I send the message it appears without any formatting in all email clients (gmail, yahoo and hotmail), and even links doesn’t appear as links, they appear as normal text but in blue. so what is the problem?

Here is the code I use to send emails:

<?php

require_once 'path/to/SwiftMailer/lib/swift_required.php';

$transport = Swift_MailTransport::newInstance();
# Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
# Create the message
$msg = Swift_Message::newInstance();
# Give the message a subject
$msg->setSubject($_POST['subject']);
# Set the From address with an associative array
$msg->setFrom(array($_POST['sender_email'] => $_POST['sender_name']));
# Give it a body
$msg->setBody($_POST['message'], 'text/html');

$failedRecipients = array();
$numSent = 0;
$to = array(
    'recipient_1@gmail.com',
    'recipient_2@yahoo.com' => 'Recipient 2',
    'recipient_3@hotmail.com',
    'recipient_4@gmail.com' => 'Recipient 4',
    'recipient_5@yahoo.com'
);

foreach ($to as $address => $name) {
    if (is_int($address)) {
        $msg->setTo($name);
    } else {
        $msg->setTo(array($address => $name));
    }

    $numSent += $mailer->send($msg, $failedRecipients);
}

echo $numSent > 0 ? 'SUCCESS' : 'FAILURE';

?>

note that $_POST['message'] holds body of the message that I have written and formatted using TinyMCE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:43:58+00:00Added an answer on June 11, 2026 at 7:43 am

    I have tried many things till I figure it out, the problem was that special characters in the formatted message body was being escaped (a back slash was being added in the front of each special character) I don’t know why, and I don’t know which of them (TinyMCE or SwiftMailer) that did this. So all I needed to do is to strip slashes out of the message body before sending the message throught SwiftMailer. I have just needed to change this line:

    $msg->setBody($_POST['message'], 'text/html');
    

    to be:

    $msg->setBody(stripslashes($_POST['message']), 'text/html');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP's SwiftMailer library to bulk send emails (following CANSPAM and RFCs). Everything
I wanna use swiftmailer to send the results of a form to a gmail
I'm currently using SwiftMailer to send out emails to several users (up to 50).
I currently use the SwiftMailer library to send email, but unfortunately it's only for
What script, class or function you use to send many emails, excluding the in-built
If i use SWIFT MAILER to send a thousand email: Not personilzed case: $message
I want to use SwiftMailer in Symfony2. To start with, I created a new
I'd like to use Sendgrid WebAPI preferably without SMTP or Swiftmailer using the code
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.