HTML emails are suddenly broken
Moderator: General Moderators
HTML emails are suddenly broken
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?
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
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.
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
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).
(that is what did it for me).
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
Is the html actually making into the function? Can you check that to make sure?
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
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?
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
Have you upgraded Swift recently? Is it possibly a bug in the app?
If not that, maybe in the mail server?
If not that, maybe in the mail server?
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
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?
Re: HTML emails are suddenly broken
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: HTML emails are suddenly broken
Server issue. I concur with you.