gpt4 book ai didi

php - php mysql 添加附件到电子邮件

转载 作者:行者123 更新时间:2023-11-29 14:33:19 24 4
gpt4 key购买 nike

大家好,我有一个时事通讯脚本,它将管理员在文本区域中输入的任何内容发送到数据库中的所有电子邮件,现在我希望该用户也能够将 .pdf 文件上传到该电子邮件,非常感谢任何帮助!这是实际发送电子邮件的代码:

Plain 是包含消息的文本区域主题就是主题需要在表单上添加一个上传输入以验证此脚本

<?php
include "connect.php";
$subject = stripslashes($_POST["subject"]);
$plain = stripslashes($_POST["plain"]);

$result = mysql_query("SELECT email FROM member");
$emails = array();
while ($row = mysql_fetch_row($result))
$emails[] = $row[0];
$subject = $_POST['subject'];
$from = "noreply@wgtfgb.com";
$headers = "From:" . $from;
$to = implode(", ", $emails);

mail($to, $_POST['subject'], $_POST["plain"], $headers);
?>
<link rel="stylesheet" type="text/css" href="view.css" media="all">
<script type="text/javascript" src="view.js"></script>
<form id='register' action='updateprofile.php' method='post' accept-charset='UTF-8'>
<body id="main_body" >

<img id="top" src="top.png" alt="">
<div id="form_container">

<h1>Newsletter Sent</h1>
<form id="form_362567" class="appnitro" method="post" action="">
<div class="form_description">
<h2>&nbsp;Newsletter Sent</h2>
<p></p>
</div>
<ul >

<li class="section_break">

<p></p>
</li> <li id="li_2" >
<label class="description" for="email">
<?php
echo "Newsletter successfully sent, you will be redirected back to the member area in 5 seconds.";
?>
</form>
<div id="footer">
<meta http-equiv="refresh" content="5; URL=index.php">
</div>
</div>
<img id="bottom" src="bottom.png" alt="">
</body>

最佳答案

使用像 SwiftMailer (http://swiftmailer.org/docs/messages.html) 这样的库...添加附件要容易得多。

关于php - php mysql 添加附件到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9609630/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com