代码之家  ›  专栏  ›  技术社区  ›  Ali Habibzadeh

phpmailer问题

  •  2
  • Ali Habibzadeh  · 技术社区  · 14 年前

    我是php新手。正在尝试发送有关用户上载的确认。我正在尝试使用php mailer来实现这一点。并有以下代码,但它不起作用。任何帮助都将不胜感激。

    <?php
    
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
        $targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
    
    // $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);
    // $fileTypes  = str_replace(';','|',$fileTypes);
    // $typesArray = split('\|',$fileTypes);
    // $fileParts  = pathinfo($_FILES['Filedata']['name']);
    
    // if (in_array($fileParts['extension'],$typesArray)) {
        // Uncomment the following line if you want to make the directory if it doesn't exist
        // mkdir(str_replace('//','/',$targetPath), 0755, true);
    
        move_uploaded_file($tempFile,$targetFile);
        echo "1";
    
    
    
    //Send confirmation email
    
    require_once('_mailClasses/class.phpmailer.php');
    include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
    
    $mail             = new PHPMailer();
    
    $body             = 'There is a new online order. Please check your order folder.';
    //$body             = eregi_replace("[\]",'',$body);
    
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "mail.splashoflondon.com";      // SMTP server
    $mail->SMTPDebug  = 2;                              // enables SMTP debug information (for testing)
    // 1 = errors and messages
    // 2 = messages only
    $mail->SMTPAuth   = true;                           // enable SMTP authentication
    $mail->Host       = "mail.splashoflondon.com";      // sets the SMTP server
    $mail->Port       = 26;                         // set the SMTP port for the GMAIL server
    $mail->Username   = "adolphus@splashoflondon.com";  // SMTP account username
    $mail->Password   = "correctpassword";                      // SMTP account password
    
    $mail->SetFrom('adolphus@splashoflondon.com', 'Splash of London');
    
    $mail->AddReplyTo("ali@xgreen.co.uk","First Last");
    
    $mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";
    
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    
    $mail->MsgHTML($body);
    
    $address = "ali@xgreen.co.uk";
    $mail->AddAddress($address, "John Doe");
    $mail->Send();
    }
    
    ?>
    
    1 回复  |  直到 14 年前
        1
  •  2
  •   webbiedave    14 年前

    由于您是php新手,我 高度地 建议您在此处查看基本的调试技术:

    http://www.ibm.com/developerworks/library/os-debug/

    这是一个很好的阅读,你会看到你的技能作为一个疑难解答跳10倍。