PHP Swiftmailer delivering incomplete emails

Posted on 2011-05-10
Last Modified: 2012-05-11

Hoping you can help me with this one. I have a standard password reset system (user inputs his email, gets sent a new password - is more complicated than that but that's the gist). The issue is, when sending the email to the user, part of the email is being cut off. I think it is something to do with line breaks, but not sure. I am using PHP and Swift Mailer (via Amazon SES if that makes a difference).

Here is the relevant code (I have tried to use the exact formatted). The message is delivered fine but only from the '' down.

Any ideas? Should I be using single quotes with \n? Is the url something to do with it?
$username="Some User";
$password1="Some Password";



Your password has been changed to - 

Username - ".$username."
Password - ".$password1."

You can now login at our login site and change this if you wish:

Please note:  this is an automated email, and as such is not monitored (so please don't reply).


$transport = Swift_AWSTransport::newInstance( AWSAccessKeyId, AWSSecretKey );

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance('Password Reset')
  ->addPart($text, 'text/plain')
  ->setFrom(array('' => 'My Domain No-Reply'))

try {
$result = $mailer->send( $message );
} catch(Exeption $e) {
// send email via mail() }

Open in new window

Question by:dosser
    LVL 7

    Expert Comment

    What happens if you change:
    ->addPart($text, 'text/plain')
    ->setBody($text, 'text/plain')

    Give that a whirl
    LVL 7

    Expert Comment

    secondly, do you have the most recent version of the AWSTransport plugin? Looks like a new one was just published on April 24:

    Author Comment

    The other thing I should have added is that it is very hard to reproduce (i.e. it doesn't happen every single time). However, enough people have reported it for it to be a problem. I have the latest AWSTransport plugin.
    LVL 7

    Accepted Solution

    well, there's nothing in the code that stands out as being wrong. I would try "SetBody()" and see what happens. Otherwise, the only thing I could suggest would be to try a different method altogether to do the mailing

    Author Closing Comment

    Difficult to solve I'll admit, when it is hard to replicate but could maybe have been more in depth with other options.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now