djp120 Posted December 19, 2007 Posted December 19, 2007 Hi, Please could anyone help me with the following... I am trying to include a php page as the body of an email. $email = require(DIR_WS_MODULES . 'email_invoice/processed.php'); tep_mail($order->customer['name'], $order->customer['email_address'], 'Your order has been processed', $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); The email is sending but returning nothing but the character "1". Any ideas? Thanks Quote
germ Posted December 19, 2007 Posted December 19, 2007 In most languages, an return status of 1 would mean success. My version of tep_mail isn't coded to return anything: function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) { if (SEND_EMAILS != 'true') return false; // Instantiate a new mail object $message = new email(array('X-Mailer: osCommerce Mailer')); // Build the text version $text = strip_tags($email_text); if (EMAIL_USE_HTML == 'true') { $message->add_html($email_text, $text); } else { $message->add_text($text); } // Send message $message->build_message(); $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject); } (found in /catalog/includes/functions/general.php) I would think since it's not coded to return any particular value, and any return code obtained would be meaningless. Use your code to send an email to yourself, as a test. If it works (or not), you have an answer to the burning question: Does my code work? Looking at what you're attempting to do: I am trying to include a php page as the body of an email. I'd say you may have to take an alternate route. I'd have to see the actual PHP code to be of any more help. Quote If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
djp120 Posted December 19, 2007 Author Posted December 19, 2007 Hi Jim, Thanks for the quick response, I think I may have had my own syntax wrong. I meant that to say that a "1" was displayed in the body of the email and that nothing is returned. oops, sorry! Basically the php pages processed.php is a html email with variables to display the products ordered as used from the order.php class. I guess what i am wondering is there a way of using something like echo with a require in order to display the html email as the body. Thanks, Dan Quote
germ Posted December 19, 2007 Posted December 19, 2007 The 4th field in the call is what determines the body of the email: function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) How are you setting the value of that field in your code? :unsure: Quote If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
djp120 Posted December 19, 2007 Author Posted December 19, 2007 The 4th field in the call is what determines the body of the email:How are you setting the value of that field in your code? :unsure: At the mo, $email = require(DIR_WS_MODULES . 'email_invoice/processed.php'); But having no luck, $email is used as the 4th field. I am thinking that i would need to use require to run the processed.php page first, else the information for that particular order will not be found??? I basically want to use that php page for the body. Quote
germ Posted December 19, 2007 Posted December 19, 2007 I'm not sure how/if you can do what you're attempting. The only thing I can think off off hand would be something like this: $email = eval("header('Location: http://www.your_site.com/catalog/modules/email_invoice/processed.php);"); (Just be sure you get the URL to the php page right) And I'm not sure that would work. :blush: Alternately, alter your processed.php to do something like this: // code in your PHP page require(DIR_WS_MODULES . 'email_invoice/processed.php'); $email = $body_text; Then the code in email_invoice/processed.php would go something like this: $body_text = echo ' this,'; $body_text .= echo ' that,'; $body_text .= echo ' and the other thing'; Basically alter all the output in email_invoice/processed.php to be concatenated to a string to be used later. Make any sense? :unsure: Quote If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
djp120 Posted December 19, 2007 Author Posted December 19, 2007 I'm not sure how/if you can do what you're attempting. The only thing I can think off off hand would be something like this: $email = eval("header('Location: http://www.your_site.com/catalog/modules/email_invoice/processed.php);"); (Just be sure you get the URL to the php page right) And I'm not sure that would work. :blush: Alternately, alter your processed.php to do something like this: // code in your PHP page require(DIR_WS_MODULES . 'email_invoice/processed.php'); $email = $body_text; Then the code in email_invoice/processed.php would go something like this: $body_text = echo ' this,'; $body_text .= echo ' that,'; $body_text .= echo ' and the other thing'; Basically alter all the output in email_invoice/processed.php to be concatenated to a string to be used later. Make any sense? :unsure: Cool, i'll give them both a try thanks, Dan Quote
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.
Note: Your post will require moderator approval before it will be visible.