如何使用Php在电子邮件中附加文件

时间:2012-11-17 15:44:23

标签: php web pear email-attachments

  

可能重复:
  Send File Attachment from Form Using phpMailer and PHP

我使用以下代码发送电子邮件...如何在电子邮件中附加文件?

@require_once "Mail.php";

                            $from = "sample@sample.com";
                            $to = $email;
                            $subject = "Sample Subject";
$body = "Hello $fname $lname";

                            $host = "smtp.gmail.com";
                            $username = "sample@sample.com";
                            $password = "sample";

                            $headers = array('From' => $from,
                                'To' => $to,
                                'Subject' => $subject);
                            $smtp = @Mail::factory('smtp', array('host' => $host,
                                        'auth' => true,
                                        'username' => $username,
                                        'password' => $password));

                            $mail = @$smtp->send($to, $headers, $body);
                            if (@PEAR::isError($mail)) {
                                echo("<p>" . $mail->getMessage() . "</p>");
                            } else {
                                echo("<font color='green'>Registration Successful, Check your email to activate your account.</font>  <a href='index.php'>Go Back</a>");
                            }

先谢谢你了:))

0 个答案:

没有答案