2014-10-17 11:21
浏览 61


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?

Here is my code :

/* subject and email varialbles*/

$emailSbuject = 'Enquiry';
$webMaster = '';
$emailSbuject2 = 'Thank you';
$client = ' $emailFeild
/*gathering data variables*/

$nameFeild = $_POST['name'];
$cityFeild = $_POST['city'];
$countryFeild = $_POST['country'];
$emailFeild = $_POST['email'];
$phoneFeild = $_POST['phone'];
$otherFeild = $_POST['other'];
$questionFeild = $_POST['question'];
$commentFeild = $_POST['comment'];
$phone1Feild = $_POST['phone1'];
$hear1Feild = $_POST['hear1'];
$hear2Feild = $_POST['hear2'];
$hear3Feild = $_POST['hear3'];
$hear4Feild = $_POST['hear4'];
$referralFeild = $_POST['referral'];
$otherhearFeild = $_POST['otherhear'];

// admin message body
$body= <<<EOD
Contact Form Details of $nameFeild

Name: $nameFeild 

City: $cityFeild 

Country: $countryFeild 

Email: $emailFeild 

Contact Phone: $phoneFeild 

Other Phone: $otherFeild 

Question: $questionFeild 

Comment: $commentFeild 

Contact Over: $phone1Feild 

Known Us through: 

// Client message body
$body2 = <<<EOD

Dear $nameFeild

         Thank u for contacting IntaxFin. One of our representatives will contact you the     soonest. If you have more questions or information needed, please let us know. We are happy to serve     you! 

         IntaxFin Team 

         Like us on Facebook 
         Follow us on Twitter 
         Connect with us on LinkedIn 

-------------------------------------------------------------------------------------------------                     e-mail was automatically sent by IntaxFin Administration Directory and is for your reference. Please do not reply to this e-mail address.

Powered by HexCode Technologies Pvt. Ltd.

    $headers = "From: $emailFeild
    $header = "From: $
    $success = mail($webMaster,$emailSbuject,$body,$headers);
    $success1 = @mail($emailFeild,$emailSbuject2,$body2,$header);

    $theResults = <<<EOD

echo  "$theResults";

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doudou0111 2014-10-17 12:01

    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: $
    MIME-Version: 1.0
    Content-Type: text/html; charset=utf-8

    Then you must update your mailcontent replacing or linebreaks with html tags <br> or even <p>

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

    <img src="">

    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= "<<<EOD
    Contact Form Details of $nameFeild
    Name: $nameFeild 
    City: $cityFeild 
    Country: $countryFeild 
    解决 无用
    打赏 举报
  • dop2144 2015-06-27 10:47
    $headers  = 'MIME-Version: 1.0' . "
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
    $message = "<html><head>
    <title>Your email at the time</title>
    <img src=\"\">
    mail($email_to, $email_subject , $message,$headers);
    解决 无用
    打赏 举报

相关推荐 更多相似问题