What are common issues when sending emails with images in PHP and how can they be resolved?

Common issues when sending emails with images in PHP include the images not displaying correctly due to incorrect paths or encoding issues. To resolve these issues, make sure to use absolute paths for the image sources and encode the images using base64 encoding before embedding them in the email.

// Example code snippet for sending an email with an embedded image
$to = 'recipient@example.com';
$subject = 'Email with embedded image';
$message = '<html><body>';
$message .= '<img src="data:image/jpeg;base64,'.base64_encode(file_get_contents('path/to/image.jpg')).'" alt="Image" />';
$message .= '</body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);