2016-12-12 11 views
1

Das ist mein html Abschnitt, erklären Sie mir bitte, was in Form Aktion zu übergeben:Wordpress - Senden Sie E-Mail mit Anhang

<form action="" method="post" enctype="multipart/form-data"> 
<div class="inputtext"><input type="text" placeholder="Fast Name*" name="fname"></div> 
<div class="inputtext"><input type="text" placeholder="Email ID*" name="email"></div> 
<div class="inputtext"> 
    <select name="bcontact"> 
    <option value="">-- Best Way to Contact --</option> 
    <option value="Phone">Phone</option> 
    <option value="Email">Email</option> 
    </select></div> 
<div class="inputtext"><input type="text" placeholder="Years Of Experience" name="experience"></div> 
<div class="inputtext"><input type="file" name="uploaded_file"></div> 
<div class="input100per"><textarea placeholder="How can we help you?" rows="5" name="message"></textarea></div> 
<div class="input100per"><input type="submit" value="Submit" name="submit"> 
<div> 
</form> 

Code: Ich brauche eine E-Mail mit Anhang wie PDF/Word-Dokument zu senden.

if (isset($_POST['submit'])) { 
global $wpdb; 
$to ='[email protected]'; 
$from = '[email protected]'; 
$name = get_bloginfo('name'); 
$attachment = $_POST['file']; 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: multipart/mixed; charset=iso-8859-1' . "\r\n"; 
$headers .= 'From: ' . $name . ' <' . $from . '>' . "\r\n"; 
$subject = 'Testing'; 
$msg = 'Yay!'; 
$mail_attachment = array($attachment); 
wp_mail($to, $subject, $msg, $headers, $mail_attachment); 
echo 'Email sent'; 
} else { 
echo 'Email not sent'; 
} 

Bitte finden Sie mir die Lösung. Vielen Dank!

Antwort

1

Ihre PHP-Code, um diese Änderung:

if (isset($_POST['submit'])) { 
    global $wpdb; 
    $to ='[email protected]'; 
    $from = '[email protected]'; 
    $name = get_bloginfo('name'); 
    $attachment = WP_CONTENT_DIR ."/Path-of-your-file/".$_POST['file']; 
    $headers = "MIME-Version: 1.0" . "\r\n"; 
    $headers .= "Content-type: text/html;charset=utf-8"."\r\n"; 
    $headers .= "From: " . $name . " <" . $from . ">" . "\r\n"; 
    $subject = 'Testing'; 
    $msg = 'Yay!'; 
    wp_mail($to, $subject, $msg, $headers, $attachment); 
    echo 'Email sent'; 
} else { 
    echo 'Email not sent'; 
} 
0

prüfen mit diesem. Bitte von E-Mail verwenden, ist "[email protected]" statt gmail.com

<?php 
if (isset($_POST['submit'])) { 
    global $wpdb; 
    $to ='[email protected]'; 
    $name = get_bloginfo('name'); 
    $headers = 'From: My Name <[email protected]>' . "\r\n"; 
    $subject = 'Testing'; 
    $msg = 'Yay!'; 
    $mail_attachment = array(WP_CONTENT_DIR . '/uploads/2012/03/image.png'); 
    wp_mail($to, $subject, $msg, $headers, $mail_attachment); 
    echo 'Email sent'; 
} else { 
    echo 'Email not sent'; 
} 
?> 
1

Seine Arbeit jetzt

if (isset($_POST['submit'])) { 

    $fname = sanitize_text_field($_POST["fname"]); 
    $lname = sanitize_text_field($_POST["lname"]); 
    $email = sanitize_email($_POST["email"]); 
    $number = $_POST["number"]; 
    $contact = $_POST["bcontact"]; 
    $position= $_POST["position"]; 

    $sName = $fname." ".$lname; 
    $subject = 'Career Form'; 
    //$to = get_option('admin_email'); 
    $attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip'); 
    $to  = '[email protected]'; 
    //$headers .= "From: $email" . "\r\n"; 
     $headers .= "Reply-To: ".$email. "\r\n"; 
     //$headers .= "CC: [email protected]\r\n"; 
     $headers .= "MIME-Version: 1.0\r\n"; 
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

    $message = '<html><body>'; 
    $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; 
    $message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>". $sName. "</td></tr>"; 
    $message .= "<tr><td><strong>Email:</strong> </td><td>" .$email. "</td></tr>"; 
    $message .= "<tr><td><strong>Phone Number:</strong> </td><td>".$number."</td></tr>"; 
    $message .= "<tr><td><strong>Best Way to Contact:</strong> </td><td>" .$contact. "</td></tr>"; 
    $message .= "<tr><td><strong>Desired Position:</strong> </td><td>".$position."</td></tr>"; 

    $message .= "</table>"; 
    $message .= "</body></html>"; 
    // If email has been process for sending, display a success message 
    if (wp_mail($to,$subject,$message, $headers,$attachments)) { 
     echo '<div>'; 
     echo '<p>Thanks for contacting me, expect a response soon.</p>'; 
     echo '</div>'; 
    } else { 
     echo 'Field markered with * required. '; 
    } 
} 
+0

Groß Sie es gelöst! Könnten Sie Ihre eigene Antwort als Lösung markieren, um Ihre Frage zu beantworten? Vielen Dank! – SaschaM78