Jump to content

Using phpmailer - File attachment problem


Connexion

Recommended Posts

Hello,

I have been working on this for a couple days on and off and have tried to find my problem but havent been able to figure it out.

I am getting the email with a jpg attachment but cant open it, it gives me an error CANNOT DETERMINE FILE TYPE.

Any help would be apreciated.
Thanks

[code]
$image_part = $Tech."_".$FirstName."_".$LastName."_".$CompletionDate."_".$HTTP_POST_FILES['Pic1']['name'];
$image_list[0] = $image_part;

require("phpmailer/class.phpmailer.php");

$mail = new PHPMailer();

$mail->From    = "myaddress@connexioncomm.com";
$mail->FromName = $From;
$mail->Subject = $FirstName." ".$LastName;
$mail->Host    = "mail.jobtrackonline.com";
$mail->Mailer  = "sendmail";

    // HTML body
    $body  = "Hello <font size=\"4\">" . "</font>, <p>";
    $body .= "Photos have been uploaded for ".$FirstName." ".$LastName."<p>";
    $body .= "Sincerely, <br>";
    $body .= "Connexion Communications, LLC";

    $mail->Body    = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress("myaddress@charter.net", "John Doe");
    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/".$image_list[0],$image_list[0]");

    if(!$mail->Send())
        echo "There has been a mail error sending to " . $row["email"] . "<br>";

    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();

[/code]
Link to comment
Share on other sites

I've never used phpMailer before, but the below line doesn't look right to me.

[code]
    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/".$image_list[0],$image_list[0]");
[/code]

You could try:
[code]
    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]");
[/code]

Also, I know that AddAttachment returns false if it can't find or access the file, if AddStringAttachment does, you could try something like this:

[code]
<?php
$attachtest = $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]");
if ($attachtest == false){
  echo "Didn't like this line\n";
}
?>
[/code]

Anyway, like I said, these are only suggestions as I've never used the class before.

Regards
Huggie
Link to comment
Share on other sites

  • 3 weeks later...
Hello,

I have some problem with attachment file by using phpmailer too, but my problem is the size of the file.
when attached file size is under 100KB, it's work well but when the attached file size over 100KB it's not work (mail does not send).

Can anyone tell me why?
Thanks.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.