Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Question about sending mails with files attached.


antagraber

Recommended Posts

Hi, Because I'd like to send emails to customers with files attached (doing from Administrator). And later on, to enhance my website giving the customers the opportunity to send me mails with attachments, I though to start by having the Add-On number (4583) (http://addons.oscommerce.com/info/4583)

 

Although a simple Add On it works partially on my OSC 2.3.1. ... It sends the message but without the attachment. Despite I feel confident enough to do small coding, I'm not an expert in the subject.

I would appreciate to have some advice from the experts in this forum about what could be wrong.

 

In my 'future' website, to let the customers send information back to our designers, is a very useful functionality. So I will appreciate all your help on this simple stuff. I spend a whole day digging on this but....without success :-(

 

This Add-On modifies the catalog\admin\mail.php file. The code updated to let send the attachment is:

 

$from = tep_db_prepare_input($HTTP_POST_VARS['from']);

$subject = tep_db_prepare_input($HTTP_POST_VARS['subject']);

$message = tep_db_prepare_input($HTTP_POST_VARS['message']);

//Let's build a message object using the email class

$mimemessage = new email(array('X-Mailer: osCommerce'));

 

if ($_FILES['userfile']['size'] > 0) {

 

$attachment_name = $HTTP_POST_FILES['userfile']['name'];

$attachment_type = $HTTP_POST_FILES['userfile']['type'];

//$attachment_size = $HTTP_POST_FILES['userfile']['size']; //Just in case you want to check and limit the size

new upload('userfile', DIR_FS_DOWNLOAD);

$attachment_file = DIR_FS_DOWNLOAD . $attachment_name;

$attachments = $mimemessage->get_file($attachment_file);

$mimemessage->add_attachment($attachments, $attachment_name, $attachment_type);

}

 

// Build the text version

$text = strip_tags($message);

if (EMAIL_USE_HTML == 'true') {

$mimemessage->add_html($message, $text);

} else {

$mimemessage->add_text($message);

}

 

$mimemessage->build_message();

while ($mail = tep_db_fetch_array($mail_query)) {

$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);

}

 

tep_redirect(tep_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));

 

 

I've also attached to this message the whole mail.php I use.

 

Thank-you very much in ahead of time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...