HTML emails are suddenly broken

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

HTML emails are suddenly broken

Post by pickle »

Hi all,

For some reason, HTML emails have started to be sent plaintext. All header information I'd send along to tell clients to read the email as HTML, are visible as plaintext in the body of the message.

I'm sure it's not my PHP code, as I've got two completely different implementations of sending HTML emails - they were both working before & they aren't any more. In fact, I'm using Swiftmailer in one implementation.

I'm guessing it's something to do with the server setup (hence my posting in this forum) - does anyone have any ideas?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Can you show the code? I only ask because the interface to Swift I wrote started sending plain text html mails today and it had to do with the way I set the mime type.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

Code: Select all

function SendMail($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles=FALSE)
{
  require_once('swiftmailer/Swift.php');
  require_once('swiftmailer/Swift/Connection/SMTP.php');
 
  $swift =& new Swift(new Swift_Connection_SMTP("mail.augustana.ca"));
  $log =& Swift_LogContainer::getLog();
  $log->setLogLevel(Swift_Log::LOG_EVERYTHING);
  $message =& new Swift_Message($Subject);
  $message->attach(new Swift_Message_Part($Text));
  $message->attach(new Swift_Message_Part($Html,"text/html"));
  if($AttmFiles)
  {
    foreach($AttmFiles as $path)
    {
      $message->attach(new Swift_Message_Attachment(new Swift_File($path),basename($path),"application/octet-stream"));
    }
  }
 
  $recipients =& new Swift_RecipientList();
  $to_list = explode(',',$To);  
  foreach($to_list as $curr_to)
  {
    $recipients->addTo($curr_to);
  }
 
  if(!$swift->send($message,$recipients,new Swift_Address($From,$FromName)))
    echo "Email was not sent";
}
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Comment out the line that set the text message part, just for testing, and see if that does it.

(that is what did it for me).
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

That causes the email to be blank completely.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Is the html actually making into the function? Can you check that to make sure?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

Not sure what you mean? The html part is being put in the email.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

That was a dumb question on my part. Have you looked at the headers in your email message that is received to confirm that the appropriate mime type is being sent?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

It doesn't look like they're being sent properly - a lot of them are showing up in the body of the email itself. It looks like the headers themselves might be buggered.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Have you upgraded Swift recently? Is it possibly a bug in the app?

If not that, maybe in the mail server?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

I haven't touched Swift in a while. Nothing about the code has changed in 1/2 a year, which is why I'm thinking it's a server config thing.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Just to check that, have you run any simple mailing tests outside of the app to see if the condition exists outside of the app?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML emails are suddenly broken

Post by pickle »

I do have another email script that sends html emails (not using Swift) & they too are broken.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: HTML emails are suddenly broken

Post by RobertGonzalez »

Server issue. I concur with you.
Post Reply