[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP Swiftmailer delivering incomplete emails

Posted on 2011-05-10
5
Medium Priority
?
686 Views
Last Modified: 2012-05-11
Hi,

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 'http://www.mydomain.com/login.php' 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";


$sender='no-reply@mydomain.com';

$text="

Your password has been changed to - 

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

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

http://www.mydomain.com/login.php

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

Thanks!
";

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

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

$message = Swift_Message::newInstance('Password Reset')
  ->addPart($text, 'text/plain')
  ->setFrom(array('no-reply@mydomain.com' => 'My Domain No-Reply'))
  ->setTo($email)
  ->setReturnPath('no-reply@mydomain.com')
  ->setReplyTo('no-reply@mydomain.com');


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

Open in new window

0
Comment
Question by:dosser
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:m4trix
ID: 35733851
What happens if you change:
->addPart($text, 'text/plain')
to
->setBody($text, 'text/plain')

Give that a whirl
0
 
LVL 7

Expert Comment

by:m4trix
ID: 35733925
secondly, do you have the most recent version of the AWSTransport plugin? Looks like a new one was just published on April 24:
https://github.com/jmhobbs/Swiftmailer-Transport--AWS-SES
0
 

Author Comment

by:dosser
ID: 35734154
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.
0
 
LVL 7

Accepted Solution

by:
m4trix earned 1500 total points
ID: 35734169
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
0
 

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to count occurrences of each item in an array.
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…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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