具有讽刺意味的是,作为一名IT承包商,我发现自己在为一家招聘咨询公司建立一个网站。
他们想要一种允许用户向他们发送简历的表单,但从安全的角度来看,他们希望将简历发送到电子邮件地址,而不是存储在网络服务器上。有没有人知道这样的事情在jquery forms插件或其他类型的脚本中是否可行?
到目前为止,谷歌等公司还没有这么好的表现。
提前谢谢。
发布于 2010-01-27 20:34:06
This页面解释了从文件上传到发送带有附件的电子邮件的所有内容
发布于 2010-01-27 20:39:01
<?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test email with attachment';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('attachment.zip')));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/zip; name="attachment.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?> 发布于 2010-01-27 20:33:45
让上传照常进行到web服务器上的临时文件夹中,然后通过电子邮件将该文件发送到需要发送到的位置,然后将其删除。
否则,它只是告诉用户在他们的简历中发送电子邮件。我想不出任何直接将文件流重定向到邮件消息的方法。
https://stackoverflow.com/questions/2146789
复制相似问题