WordPress.org

Ready to get started?Download WordPress

Forums

Quick Contact Form
[resolved] Adding Attachment to the Mail (5 posts)

  1. Tanshaydar
    Member
    Posted 1 year ago #

    Hi;
    Thanks for the plugin. It works great; except two things.

    First, plugin was unable to send mails. I saw that my host has disabled PHP mail function. I have been forced to switch to using SMTP, with WP's wp_mail function. For that part, it was easy.
    I just changed
    mail($qcf_email, $subject, $message, $headers);
    to
    wp_mail( $qcf_email, $subject, $message, $headers);
    it works flawlessly.

    However, I need to send attachments to mail too. When I added $attach as a new variable to the function, it didn't work.
    Is it possible to send the attachment with mail?

    Regards.

    http://wordpress.org/extend/plugins/quick-contact-form/

  2. aerin
    Member
    Plugin Author

    Posted 1 year ago #

    I've already been testing this solution to see if it solves the PHP mail problem. It seemed to work OK but you are giving me more confidence.

    If you want to send attachments don't add $attach as a new variable to the function. It's an array anyway and I can't get the built in WP function to behave. The MIME boundaries are delicate creatures and when you send the attachment it doesn't display properly in the email client.

    So just use:

    wp_mail( $qcf_email, $subject, $message, $headers);

    and let the plugin look after the attachments for you

  3. Tanshaydar
    Member
    Posted 1 year ago #

    I see. I figured as much that $attach was an array and tried a few different array members to display but no dice.
    Well, at least it sends the mail just fine. However, where can I view the attachment if there is any? I can't seem to find where it is uploaded or displayed for that matter.

  4. aerin
    Member
    Plugin Author

    Posted 1 year ago #

    The attachment is held to a temporary file, processed then forwarded to the recipient.

    It doesn't get uploaded as such, it gets chopped into bits, sent as chunks and reassembled at the other end. If you want to view/save the attachment then you have to log into your email account.

  5. aerin
    Member
    Plugin Author

    Posted 1 year ago #

    A couple of links for you:

    Emails with attachments are sent as MIME objects:
    wikipedia.org/wiki/MIME

    The script used to create the MIME object looks like this:
    Email attachment script

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic