sawade Posted November 10, 2009 Share Posted November 10, 2009 I have no issues with this code if I take out the attachement section and include the info in the email body instead. However, I want the info to be in an email attachment. I do receive the email, but it is blank. No attachment, no info being passed into the email at all. Headers and everything else is fine as well. Any ideas? Thanks. require_once "Mail/mail.php"; require_once "Mail/mime.php"; require_once "Crypt/GPG.php"; require_once "Constants.php"; if ($send_attachment_as == 'CSV') { //Creates CSV file $cr = "\n"; $csvData = "Last" . ',' . $last_name . $cr; $csvData .= "First" . ',' . $first_name . $cr; $csvData .= "MI" . ',' . $middle_name . $cr; $csvData .= "Input would continue..." . ',' . $cr; //Open the file $filehandler = fopen("csvdemo.csv","a") or die("Can't write file."); fwrite($filehandler,$csvData); // Write information to the file fclose($filehandler); // Close the file $text = "Please see the attached document for a recently submitted Form."; $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" /> </head> <body> <p>Please see the attached document for a recently submitted Form.</p> </body></html>'; $file = 'csvdemo.csv'; $crlf = "\n"; $to = 'email address'; $hdrs = array( 'From' => MAILER, 'Subject' => "CSV $date", 'Reply-to' => MAILER ); $smtp["host"] = SMTP_HOST; $smtp["port"] = SMTP_PORT; $smtp["auth"] = true; $smtp["username"] = SMTP_USERNAME; $smtp["password"] = SMTP_PASSWORD; $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($html); $mime->addAttachment($file, 'application/vnd.ms-excel'); $body = $mime->get(); $hdrs = $mime->headers($hdrs); // Encryption require_once "Constants.php"; $data = $body; $gpg = new Crypt_GPG(); $gpg -> addEncryptkey(GPG_SECURE); $encrypted = $gpg -> encrypt($data); $mail = Mail::factory('smtp', $smtp); $mail->send($to, $hdrs, $encrypted) or die('Error while processing your submission.'); //Delete Created File unlink($file); } Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/ Share on other sites More sharing options...
sawade Posted November 11, 2009 Author Share Posted November 11, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-955876 Share on other sites More sharing options...
sawade Posted November 12, 2009 Author Share Posted November 12, 2009 I have doubled and triple checked to make sure the encryption keys are working properly, and again I can get a regular email encryted, sent and decrypted. But as soon I put the attachment code in and try it, I get a blank email that can't be decrypted... I am assuming it can't be decrypted because there is no info in the email to decrypt. I have tried everything I can think of, and it always ends in the same result... a blank email. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-956119 Share on other sites More sharing options...
sawade Posted November 13, 2009 Author Share Posted November 13, 2009 Am still not having any luck. I work on this in part or in whole each day. I'm sure I am missing something small... :'( Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-956808 Share on other sites More sharing options...
sawade Posted November 16, 2009 Author Share Posted November 16, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-958500 Share on other sites More sharing options...
sawade Posted November 17, 2009 Author Share Posted November 17, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-959220 Share on other sites More sharing options...
sawade Posted November 18, 2009 Author Share Posted November 18, 2009 Does no one know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-959904 Share on other sites More sharing options...
sawade Posted November 19, 2009 Author Share Posted November 19, 2009 Any educated guesses out there? Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-961358 Share on other sites More sharing options...
sawade Posted November 20, 2009 Author Share Posted November 20, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-961905 Share on other sites More sharing options...
sawade Posted November 23, 2009 Author Share Posted November 23, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-963879 Share on other sites More sharing options...
sawade Posted November 24, 2009 Author Share Posted November 24, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-964692 Share on other sites More sharing options...
sawade Posted November 25, 2009 Author Share Posted November 25, 2009 :-\ Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-965430 Share on other sites More sharing options...
sawade Posted November 30, 2009 Author Share Posted November 30, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-968267 Share on other sites More sharing options...
sawade Posted December 1, 2009 Author Share Posted December 1, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-969036 Share on other sites More sharing options...
sawade Posted December 2, 2009 Author Share Posted December 2, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-970125 Share on other sites More sharing options...
premiso Posted December 2, 2009 Share Posted December 2, 2009 Have you tried doing some basic debugging by outputting the encrypted, testing that the file was created and contained data? Have you tried removing the encryption part and seeing if that sends? In all of the bumps you failed to tell if you have tried anything or just waited for a response. The reason you are getting lack of responses is the PEAR package, not many people want to install the exact setup just to test and see how to get your script to work, sorry. But for the most part you are going to have to just debug this old fashioned way with trial and error until you figure out what is wrong. How I would approach this problem: Take out all the complex stuff and create a script that simply sends a test.csv file (that is already created in the folder the script is in) and send that, with nothing else. If that sends fine, slowly add more items, if it does not you now know your problem lies with PEAR and can at least pin point why it is not sending properly. But your first problem is testing that you can indeed send a file and receive it without all the extra stuff, if that is where the problem lies figure out how to fix it then add on from there. Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-970137 Share on other sites More sharing options...
sawade Posted December 2, 2009 Author Share Posted December 2, 2009 Yeah, everything works great until I input the encryption block... $data = $body; $gpg = new Crypt_GPG(); $gpg -> addEncryptkey(GPGCONSTANT); $encrypted = $gpg -> encrypt($data); If I remove this the code works fine. I am beginning to wonder if PEAR is not compatible with the encryption or if I need another PEAR componet that I haven't found yet. Baffeling. Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-970141 Share on other sites More sharing options...
premiso Posted December 2, 2009 Share Posted December 2, 2009 Well after doing some reading (really hard to find much information on this) I have come to a conclusion that something in PEAR stops this or you are missing a needed step, which I do not know what it is. How about sending the message un-encrypted and just encrypting the attachment? Or try encrypting the attachment before you attach it as well as the message, maybe you have to them both encrypted for it to work? I do have to say I know nothing about this cause I never used the GPG encryption method, so yea. I am just grabbing at straws. Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-970153 Share on other sites More sharing options...
sawade Posted December 3, 2009 Author Share Posted December 3, 2009 Well after doing some reading (really hard to find much information on this) I have come to a conclusion that something in PEAR stops this or you are missing a needed step, which I do not know what it is. How about sending the message un-encrypted and just encrypting the attachment? Or try encrypting the attachment before you attach it as well as the message, maybe you have to them both encrypted for it to work? I do have to say I know nothing about this cause I never used the GPG encryption method, so yea. I am just grabbing at straws. It is very hard finding info on this. That is an idea though. I will try to encryption the file and then attach it into the email. I will post after I have tried that. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/180998-pear-email-attachment-w-gpg/#findComment-970163 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.