How to send image in PHP mail function

后端 未结 2 1812
盖世英雄少女心
盖世英雄少女心 2020-12-10 09:57

I want to send image in mail.How to add image so that it will show in the email I want to add image to the CLIENT MESSAGE BODY. How to use html in client message body?

2条回答
  •  臣服心动
    2020-12-10 10:49

    You cannot display images on text/plain emails as shown above. You must send it as text/html.

    So you first have to extend your headers like this:

    $header = "From: $noreply@intaxfin.com\nMIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n";
    

    Then you must update your mailcontent replacing \n or linebreaks with html tags
    or even

    Then you also can include image tags having the image you want to show in the email

    
    

    This will be downloaded from your webserver when recipient opens it.

    .

    BUT the much better way will be to use phpMailer Class

    Using this, you will be able to include any images IN your email, without need to download it from any website. It is easy to learn and absolutely customizable.

    By the way: You should use quotation marks for your $body and $body2 values...

    $body= "<<

提交回复
热议问题