Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering if there was a plugin that could do the following:

  1. user goes to page on wordpress site
  2. user fills out their email address
  3. Clicks Email Form button
  4. user gets an email from my preconfigured email address via the plug with an attachment I have on my wordpress server somewhere, and some text explaining how to fill out the form or something.
share|improve this question
    
I believe this is exactly what I'm looking for - do I place the PHP code in the functions.php of the theme I'm using? In this case, i'm using a Genesis child theme. –  user9027 Sep 28 '11 at 19:30

1 Answer 1

you can use wp_mail( $to, $subject, $message, $headers, $attachments ); to send emails with attachments.

So all you need is a simple form

<form name="email-att" id="email-att" method="POST" action="">
Enter your emial: <br />
<input type="text" name="email" id="email"/><br />
<input type="hidden" name="action" value="email-att"/><br />
<input type="submit" name="submit" value="submit" id="submit"/>
</form>

and to process it

<?php
if (isset($_POST['action']) && $_POST['action'] == "email-att"){
   if (is_email($_POST['email'])){
        $to = $_POST['email'];
        $subject = "email subject line";
        $message = "email message body";
        $attachments = array('http://full_url_to_file.zip');
        wp_mail( $to, $subject, $message, '', $attachments );
        echo 'mail sent! check your email';
    }else{
        echo 'Please enter a valid email address ';
    }
}
?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.