php send email with image

前端 未结 3 1305
广开言路
广开言路 2021-01-26 17:30

I am trying to send an email with a picture; the body of my email is:



        
3条回答
  •  一整个雨季
    2021-01-26 18:11

    To answer your question, you need to send out content headers that sets the content type to text\html. Without it, your message is treated as plain text by the receiving client. The following code sets the content headers properly and sends out a basic HTML message.

    // message
    $message = '
    
    
      
    
    
    ';
    
    // Add the content headers
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    $headers .= 'To: David ' . "\r\n";
    $headers .= 'From: Bot ' . "\r\n";
    
    mail("david-z@domain.com", "mysubject", $message, $headers);
    

提交回复
热议问题