0

I am sending an Email from my server through SMTP Gmail using Pear's Mail Mime. However when I add an attachement it simply does not show up.

$smtpinfo["host"] = "ssl://smtp.gmail.com";  
$smtpinfo["port"] = "465";  
$smtpinfo["auth"] = true;  
$smtpinfo["username"] = "xxx";  
$smtpinfo["password"] = "xxx";  

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

$mime = new Mail_mime();

$mime->setHTMLBody($html);

$mime->addAttachment("http://ww.url.of.a.file.that.exists.100percent.jpg", "image/jpeg");

$body = $mime->get(array('html_charset' => 'utf-8','charset' => 'utf-8'));

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

$smtp = Mail::factory('smtp', $smtpinfo);

$mail = $smtp->send($to, $headers, $body);

Everything works fine just the attachement is entirely missing.. I've been googling for hours.. I appreciate any hints..

elMeroMero
  • 752
  • 6
  • 18

1 Answers1

0

My first thoughts would be to check the [boolean] response of the addAttachment method to see if it returns 'not found' or other type of indication(s)

$fileAttached = $mime->addAttachment("http://ww.url.of.a.file.that.exists.100percent.jpg", "image/jpeg");
echo ( !empty($fileAttached) ) ? "Attached successfully!" : "Uh, Houston?";

My initial thought is that it's expecting that 'file' to be 'loca' to your system and not accessed via http, etc. And, even if it DOES allow for HTTP access, you might also want to check your allow_url_fopen in the .ini file to insure it's set to 'enabled' {"On" if looking at your phpinfo() result.

Additional information on the 'file' -

http://pear.php.net/manual/en/package.mail.mail-mime.addattachment.php
Bill Ortell
  • 837
  • 8
  • 12