Jump to content

Recommended Posts

Hi i am new to PHP scripts but am learning fast.

 

I have apache, PHP and pear installed and am trying to send an email with a .jpg file attatched.

 

I have just about managed to do this with a lot of searching on the net.

 

HOWEVER, the receiving mail does not display the picture, (example@yahoo.com) it displays

a blank thumbnail. If I send the same message, from the same email to the same email from

outlook the receiving mail displays the picture as a thumbnail.

 

WHY IS THIS HAPPENING ???

 

Can anyone solve this problem.  Here is the code I found to use.  THANK YOU.

 

 

Using Pear mail.php  and mime.php

 

 

 

<?php

require_once "c:/php/pear/mail/Mail.php"; // PEAR Mail package

require_once ('c:/php/pear/mime/mime.php'); // PEAR Mail_Mime packge

 

$from = "info@*******.com";

$to = "example@yahoo.com";

$subject = 'Picture from info@******.com';

 

$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);

 

$text = 'Text version of email';// text and html versions of email.

//$html = '<html><body>HTML version of email. <strong>This should be bold</strong></body></html>';

 

$file = 'C:/pics/testpic1.jpg'; // attachment

$crlf = "\n";

$mime = new Mail_mime($crlf);

$mime->setTXTBody($text);

$mime->setHTMLBody($html);

$mime->addAttachment($file, 'text/plain');

 

//do not ever try to call these lines in reverse order

$body = $mime->get();

$headers = $mime->headers($headers);

 

//Smtp email authentication

 

$host = "mail.*******.com";

$username = "info@*******.com";

$password = "**********";

 

$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("<p>Message successfully sent!</p>");

}

?>

Thanks for that. No is not that.

 

If i send from  email1@*****.com to  email2@yahoo.com  via the PHP code then no picture is displayed, it is a blank thumbnail.

but the image can be downlaoded.

 

 

If i send from  email1@*****.com to  email2@yahoo.com  via outlook, then the picture is displayed in the receiving mail.

 

Confusing the H*** out of me.

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.