PHPMailer attachment

Discussion in 'PHP' started by fr33d0m, Aug 1, 2007.

  1. #1
    Hi, i read PHPMailer tutorial that we can put a relative path for attachment.
    But it just doesn't attach the file to my email.
    Can someone help me, pls?
    Thanks in advance...

    Below is my code :
    
    //Check the domain name, i.e if it is a gmail account use PHPGmailer to send the mail
    $splitString = strstr($sentTo, '@');
    $getDomain = substr($splitString, 1, strlen($splitString));
    
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "203.117.178.47";
    $mail->Port = 25;
    $mail->SMTPAuth = true;
    $mail->Username = "admin@sig-share.com";
    $mail->Password = "glamour";
    
    $mail->From = "admin@meninwhite.com.sg";
    $mail->FromName = "Sig-Share's Admin";
    $mail->Sender = $mail->From;
    $mail->AddReplyTo("admin@sig-share.com","Information");
    $mail->AddAddress($user);
    
    // set word wrap
    $mail->WordWrap = 50;
    //----Attachment Part ------
    			$mail->AddAttachment("http://innoform.no-ip.com/site/license/" . $licenseName);
    // send as HTML
    $mail->IsHTML(true);
    
    $mail->Subject = "License for Sig-Share's iViewer";
    $mail->Body = $msg;
    
    if(!$mail->Send())
    {
        $_SESSION["dlViewerMsg"] = "License was not sent, reason : $mail->ErrorInfo";
       header("Location: http://innoform.no-ip.com/site/download_viewer.php");
    }
    else {
       header("Location: http://innoform.no-ip.com/site/dlViewer.php");
    }
    
    Code (markup):

     
    fr33d0m, Aug 1, 2007 IP
  2. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That isn't a relative path - that's a url.

    A relative path would be something like "./license/".$licenseName

    or...

    "/var/www/html/yoursite/license/".$licenseName"

    or...

    "../../license/".$licenseName
     
    ecentricNick, Aug 1, 2007 IP
  3. Tarkan

    Tarkan Peon

    Messages:
    491
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If this becomes too complicated, scrolling around PHP.net/mail or googling around for attachments and making your own functions would be just as good.
     
    Tarkan, Aug 1, 2007 IP