Solved

attach image in sendmail

Posted on 2009-04-06
4
820 Views
Last Modified: 2012-05-06
Hello,

I am sending an email with an attachment(image) using php function sendmail,
the mail sending is successful, image is also attached to the mail.
But when I open the image file it won't open, it just shows "No preview available."
And the file name that is attached to email is part1.2, though the file that I attach has a diff name.
function sendmail($name,$mail,$image)
	{
	  	define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
		require_once 'C:/AppServ/www/abcde/mail/MAIL.php'; // path to 'MAIL.php' file from XPM4 package
		$m = new MAIL; // initialize MAIL class
		$m->From('abc@abc.com'); // set from address
		$m->AddTo('abc@abc.com'); // add to address
		$m->Subject('Verification request.'); // set subject
		$m->Text("$name has requested verification. \nAttached image for verification."); // set text message
		$m->Attach("components/com_jumi/verification/".$image ,"image/jpeg");
		$m->Send();
	}

Open in new window

0
Comment
Question by:Suhashk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:anvanster
ID: 24084304
Hi,
Try using this:

$m->AddEmbeddedImage("/images/image.jpg", "image-attachment", "image.jpg");

Open in new window

0
 

Author Comment

by:Suhashk
ID: 24084514
I am getting this error:

Fatal error: Call to undefined method MAIL::AddEmbeddedImage() in C:\AppServ\www\DatingSite\components\com_jumi\jumi.php(25) : eval()'d code on line 13

line no. 13 in jumi.php:
$user      = &JFactory::getUser();
0
 
LVL 4

Expert Comment

by:anvanster
ID: 24084579
Sorry, I'm using this function to send mail
$mail = new PHPMailer();
//$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "www.wowdemon.net"; // SMTP server
$mail->From     = "jasonv@gmail.com";
$mail->FromName = "Administrator";
$mail->AddAddress("jasonv@gmail.com"); 
$mail->WordWrap = 50;                              // set word wrap
$mail->AddEmbeddedImage("/images/imageo.jpg", "my-attach", "image.jpg");
$mail->Body = '<img alt="PHPMailer" src="cid:my-attach">  ';
$mail->IsHTML(true);                               // send as HTML
 
$mail->Subject  =  "image !!!!!!!!";
$mail->AltBody  =  "This is the text-only body";
 
if(!$mail->Send())
{
   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}
 
echo "Message has been sent";

Open in new window

0
 
LVL 14

Accepted Solution

by:
shobinsun earned 125 total points
ID: 24084662
Hello,

Please look at the link:

http://www.aslme.org/conferences/cdc_credits/phpdoc/PHPMailer/PHPMailer.html

Read carefully about the AddEmbeddedImage() method.

Regards.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Node.js 11 77
PHP processing webform 25 44
PHP MYSQLI Connection in Function in a class 4 28
sitemap.xml 3 27
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question