Script to send an image by e-mail

How to write a link to the image in this script so that the image is sent by e-mail?

<?
define('SITE',true);
include("../admin/conf.php");
if($_GET['k']!=md5($c['admin_mail']))die();
$all=mysql_query("SELECT * FROM jb_subscribe LIMIT ".$c['subscribe_limit']);cq();
$countmail=0;
while($d=mysql_fetch_assoc($all)){
    $subject=$c['subscribe_theme'];
    $subject=str_replace("[HOST]",$h,$subject);
    $subject=str_replace("[REGISTER_PAGE]",$h."register.html",$subject);
    $subject=str_replace("[USER_NAME]",$d['username'],$subject);
    $subject=str_replace("[USER_ADS]",$h."c".$d['id_cat']."-".$d['id_board'].".html",$subject);
    $msg=$c['subscribe_text'];
    $msg=str_replace("[HOST]",$h,$msg);
    $msg=str_replace("[REGISTER_PAGE]",$h."register.html",$msg);
    $msg=str_replace("[USER_NAME]",$d['username'],$msg);
    $msg=str_replace("[USER_ADS]",$h."c".$d['id_cat']."-".$d['id_board'].".html",$msg);
    $from=(@$c['subscribe_from']!="")?$c['subscribe_from']:$c['admin_mail'];
    if(sendmailer($d['mail'],$from,$subject,$msg)){
        mysql_query("DELETE FROM jb_subscribe WHERE id='".$d['id']."' LIMIT 1");$countmail++;sleep($c['subscribe_sleep']);
    } 
}
echo $lang[1074].": ".$countmail;
?>

Answer 1, authority 100%

The picture will come only if the source of the picture is attached to the letter itself.

to the end of the file, separating the letter with a separator, setting the necessary headers:

$bound="---Ya_Tipa_RazDelitel---";
$body="--$bound\n";
$body.="Content-type: text/html; charset=\"windows-1251\"\n";
$body.="Content-Transfer-Encoding: 8bit\n\n";
$body.="
       <img src=\"cid:my_pic_img_1\">   
    <img src=\"cid:my_pic_img_2\"> -    
";
$body.="\n\n--$bound\n";
$body.="Content-Type: image/jpeg; name=\"".basename($file_name)."\"\n";
$body.="Content-Transfer-Encoding:base64\n";
$body.="Content-ID: <my_pic_img_1>\n\n";
//   
$f=fopen($file_name,"rb");
$body.=base64_encode(fread($f,filesize($file_name2)))."\n";
$body.="--$bound--\n\n";
$body.="Content-Type: image/jpeg; name=\"".basename($file_name2)."\"\n";
$body.="Content-Transfer-Encoding:base64\n";
$body.="Content-ID: <my_pic_img_2>\n\n";
//   
$f=fopen($file_name2,"rb");
$body.=base64_encode(fread($f,filesize($file_name2)))."\n";
$body.="--$bound--\n\n";

This was the body of the email.
In this case, the Content-type of the letter should be: multipart/alternative;


Answer 2, authority 50%

If I understand the task correctly, something like this:

$msg=$c['subscribe_text'];

change to

$msg=$c['subscribe_text'].'<br />- <br /><img src="'.$h.'///." />';

Try it.


Answer 3

addAttachment($file, 'image/png /*  */');

Normal people do this. But what kind of script and what kind of admin is it from – this is already a question for you. It sucks to understand other people’s code. In general, you should also include the sendmailer () function in the description. Is this a bulletin board?