0

Hi,

I have query in image sending in mail. I am trying to send image to mail id and display that image in mail id. below code i tryed to wrote and it is not displaying that image. In LIVE only i have tryed to send that mail it is not displaying image, but it is display subject, and message.

case "add_news":
             $con=getConnection();
             $type = $_FILES['file1']['type'];	
             $size = $_FILES['file1']['size'];
             $name = $_FILES['file1']['name'];	
             $src_path = $_FILES['file1']['tmp_name'];
             $error = $_FILES['file1']['error'];	
             $up_fl = "../images/newsletters";
             $item_img = $up_fl.rand().$name;
             $upload = move_uploaded_file($src_path,$item_img);
             $from="info@jh.co.in";


      $headers = "Content-Type: text/html; charset=iso-8859-1\n"; 
      $headers .= "From: $from\r\n"; 


       $sql="select r_email from customer_registration ";
       $res=mysql_query($sql,$con) or die(mysql_error());
       while($row=mysql_fetch_array($res))
       { $posts[]=$row['r_email'];
       }
       foreach($posts as $post) {
          $message="   ".$_POST['subject']."   \n ";
          $message.="  ".$_POST['message']. " \n";
          $message.="<br> <a href='".$item_img. " ' > <img      src='".$item_img."' alt='' width='250' height='250'  ></a> \n";
        
        if(mail($post, $_POST['subject'],$message,$headers)){
              $sql="insert into newsletter(`subject`,`message`,`image`,`sendate`) 
values('".$_POST['subject']."','".$_POST['message']."','".$item_img."','".date('Y/m/d')."' )";
              $res=mysql_query($sql,$con)or die(mysql_error());
        }
        echo "<script language='javascript'>window.location.href='index.php?option=show_newsletters';</script>"; 
       }
break;

Can anyone give solution, how to write the code for send image and display that in mail id.

Regards,

Ravi

Edited by nav33n: Please use [code][/code] tags to wrap your code for easy readability.

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Arsench
0

Hi,

I have query in image sending in mail. I am trying to send image to mail id and display that image in mail id. below code i tryed to wrote and it is not displaying that image. In LIVE only i have tryed to send that mail it is not displaying image, but it is display subject, and message.

case "add_news":
             $con=getConnection();
             $type = $_FILES['file1']['type'];	
             $size = $_FILES['file1']['size'];
             $name = $_FILES['file1']['name'];	
             $src_path = $_FILES['file1']['tmp_name'];
             $error = $_FILES['file1']['error'];	
             $up_fl = "../images/newsletters";
             $item_img = $up_fl.rand().$name;
             $upload = move_uploaded_file($src_path,$item_img);
             $from="info@jh.co.in";


      $headers = "Content-Type: text/html; charset=iso-8859-1\n"; 
      $headers .= "From: $from\r\n"; 


       $sql="select r_email from customer_registration ";
       $res=mysql_query($sql,$con) or die(mysql_error());
       while($row=mysql_fetch_array($res))
       { $posts[]=$row['r_email'];
       }
       foreach($posts as $post) {
          $message="   ".$_POST['subject']."   \n ";
          $message.="  ".$_POST['message']. " \n";
          $message.="<br> <a href='".$item_img. " ' > <img      src='".$item_img."' alt='' width='250' height='250'  ></a> \n";
        
        if(mail($post, $_POST['subject'],$message,$headers)){
              $sql="insert into newsletter(`subject`,`message`,`image`,`sendate`) 
values('".$_POST['subject']."','".$_POST['message']."','".$item_img."','".date('Y/m/d')."' )";
              $res=mysql_query($sql,$con)or die(mysql_error());
        }
        echo "<script language='javascript'>window.location.href='index.php?option=show_newsletters';</script>"; 
       }
break;

Can anyone give solution, how to write the code for send image and display that in mail id.

Regards,

Ravi

Hello , the image path is incorrect.

try this

$up_fl = "http://www.YOUR_DOMAIN.com/images/newsletters";

When the recipient receives the email, it trying to load image from his local folders, so it can’t be found so you have to define the image path completely and try to display.
regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.