0

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.
1
  • 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, 2011 at 19:30

1 Answer 1

2

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 ';
    }
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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