File Attachment problem with PHPMailer class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrbadboy
    New Member
    • Jul 2007
    • 21

    File Attachment problem with PHPMailer class

    Hi,

    I tried to send a mail with PHPMail class. Its sending properly if i write the attachment file name directly( I have mentioned my code bellow)

    [code=php]
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "192.168.111.11 1";
    $mail->SMTPAuth = true;
    $mail->Username = "";
    $mail->Password = "";
    $mail->From = "test@yahoo.com ";
    $mail->FromName = "Mailer";
    $mail->AddAddress("te st@yahoo.com"," TestName");
    $mail->WordWrap = 50;
    $mail->AddAttachment( "test.doc") ;
    $mail->IsHTML(true) ;
    $mail->Subject = "Here is the subject";
    $mail->Body = "This is the <b>HTML body</b>";
    $mail->AltBody = "This is the text-only body";

    if(!$mail->Send())
    {
    echo "Message was not sent <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
    }
    [/code]

    If i get the file name from previous page its shows an error Language string failed to load: file_access'/tmp/phpNcvep9'.

    How can i solve this problem.

    Thanks.
    Last edited by Atli; Oct 7 '07, 05:41 PM. Reason: Added [code] tags.
  • bergy
    New Member
    • Mar 2007
    • 89

    #2
    I have never used that class before, but could it be that you need to specify the full path to your file?

    On Linux: [PHP]$mail->AddAttachment( "/var/www/httpdocs/mysite.com/home/test.doc"); [/PHP]
    On Windows: [PHP]$mail->AddAttachment( "C:\\My Docs\\test.doc" ); [/PHP]

    That's the only thing I could think of having no experience with the PHPMailer class.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      Please use [code] tags when posting code! (Read the box on the right when you post).

      As for your problem.
      Could you show use the code you use to pass the file name from the previous page?

      Comment

      Working...