sawade Posted January 10, 2010 Share Posted January 10, 2010 The code does create and send the email successfully. However, the message shows as html code and not an html email. Any ideas what is causing this? Thanks. // Email require_once "/mail.php"; require_once "/mime.php"; require_once "/Crypt/GPG.php"; require_once "/EDITED FOR PRIVACY"; $to = FORM_MAILER; $crlf = "\n"; $hdrs = array( 'From' => EDITED, 'Subject' => "Test Email - Received $date", 'Reply-to' => EDITED ); $smtp["host"] = SMTP_HOST; $smtp["port"] = SMTP_PORT; $smtp["auth"] = true; $smtp["username"] = SMTP_USERNAME; $smtp["password"] = SMTP_PASSWORD; $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <style type="text/css"> * { margin: 0; padding: 0; } </style> </head> <body> <div id="body"> <h1>TEST</h1> <p><br /></p> <p>TEST</p> <p><br /></p> <table> <tr> <td>Date:</td> <td>' . $date . '</td> <td></td> <td></td> </tr> <tr> <td>First Name:</td> <td>' . $first_name . '</td> <td>Last Name:</td> <td>' . $last_name . '</td> </tr> </table></div></body></html>'; $mime = new Mail_mime($crlf); //$mime->setTXTBody(strip_tags($html)); $mime->setHTMLBody($html); //$mime->addAttachment(); // Encryption $data = $mime->setHTMLBody($html); $gpg = new Crypt_GPG(); $gpg -> addEncryptkey(GPG_SECURE); $encrypted = $gpg -> encrypt($data); $body = $mime->get(); $hdrs = $mime->headers($hdrs); ob_start(); $mail = Mail::factory('smtp', $smtp); $mail->send($to, $hdrs, $encrypted) or die('Error while processing your submission.'); ob_end_clean(); I am thinking it is the gpg that is causing the issue. But all my attempts to get around it aren't going well. If I take out the gpg the email is received fine. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/187981-html-email-recd-as-source-code/ Share on other sites More sharing options...
jeremy0 Posted January 11, 2010 Share Posted January 11, 2010 This is on-topic, my question here is related. You are using gnuPg for encryption of this email - why? If you need to transmit the message in an encrypted format, just use ssl-encryption with your $mail, should be included in the package you use to send the email. Otherwise, if you need this additional encryption, my guess is that you are correct that encrypting the message with gnuPg is causing the email client on the recipient's end to mis-handle the data format. I would recommend that if you need to send an encrypted message, just send it through ssl. Otherwise you would have to play with low-level email protocols and that is no-fun (I've had to send meeting invites programmatically to gmail and outlook - no fun trying to get those to work correctly in both with html formatted emails and full functionality) -jeremy0 Link to comment https://forums.phpfreaks.com/topic/187981-html-email-recd-as-source-code/#findComment-992540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.