0

如何将我的电子邮件附件表单连接到 php。直接我的电子邮件。

html:-

  <form id="form" class="blocks" enctype="multipart/form-data" action="js/upload_file.php" method="post">
    <p>
        <label>
            Name:</label>
        <input type="text" class="text" name="name" />
    </p>
    <p>
        <label>
            Address:</label>
        <input type="text" class="text" name="address" />
    </p>
    <p>
        <label>
            Phone:</label>
        <input type="text" class="text" name="phone" />
    </p>
    <p class="area">
        <label>
            Year Exp:</label>
        <input type="text" class="text" name="exp" />
    </p>

                      <p class="area">
        <label for="file">
            Upload ur CV:</label>
        <input type="file" name="attachment">
    </p>
    <p>
        <label>
            &nbsp;</label>
        <input type="submit" class="btn" value="Submit" />
    </p>
 </form>

    <div class="right">
        <img src="images/Careers.png" width="350" height="334">
    </div>

    </div>
            </div>

    </div>

如何将我的电子邮件附件表单连接到 php。直接我的电子邮件。如何将我的电子邮件附件表单连接到 php。直接我的电子邮件。如何将我的电子邮件附件表单连接到 php。直接我的电子邮件。

PHP :-

 <?php
if (isset($_REQUEST['email']))
{
  $domain='www.example.com';
  $from='www.example.com';
  $name = $_REQUEST['name1'] ;
  $add = $_REQUEST['add'] ;
  $phone = $_REQUEST['phone'] ;
  $exp = $_REQUEST['exp'] ;
  $attachment = $_REQUEST['attachment'] ;
    $subject = 'Massage recieved from Pearl : '.$domain.'';
    $body = $email.'

    The person that contacted you is : '.$name.'

    |------------------Full Details--------------------|

   Name:            '.$name.'
     Address:          '.$add.'
     Phone:          '.$phone.'
     Experience:         '.$exp.'
     Attachment:         '.$attachment.'

    |--------------------End---------------------------|'; 
  echo ("<SCRIPT LANGUAGE='JavaScript'>
    window.alert('Thank you for your feedback. We will contact you shortly')
    window.location.href='http://www.pearlgroup.asia';
    </SCRIPT>");  

mail("info@example.com",$from, $subject, $body);

// Check, if message sent to your email 
// display message "We've recived your information"

}
else
{
echo "Try again";
}
?>`
4

2 回答 2

0

如果我理解你的问题:http ://webcheatsheet.com/PHP/send_email_text_html_attachment.php

希望能帮助到你。

于 2013-10-07T06:43:51.803 回答
0

基于这篇使用梨库的文章(http://www.html-form-guide.com/email-form/php-email-form-attachment.html),在你得到附件并处理它之后,然后你可以使用邮件库发送电子邮件...

$message = new Mail_mime(); 
$message->setTXTBody($text); 
$message->addAttachment($path_of_uploaded_file); 
$body = $message->get(); 
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email); 
$headers = $message->headers($extraheaders); 
$mail = Mail::factory("mail"); 
$mail->send($to, $headers, $body);

如果你想使用 swift ( http://swiftmailer.org/ ),逻辑还是一样的......

$message = Swift_Message::newInstance('Subjct', 'Body message');
$message->attach(Swift_Attachment::fromPath('/path/to/file'));
于 2013-10-07T06:47:24.647 回答