Doubt with sending HTML email with SSMTP from linux

0

Hello friends, I have the following code:

$to = '[email protected], [email protected]';

$subject = 'Website Change Reqest';


$message = '<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test HTML</title>
</head>
<body style="margin:0px; background: #f8f8f8; ">
<div width="100%" style="background: #f8f8f8; padding: 0px 0px; font-family:arial; line-height:28px; height:100%;  width: 100%; color: #514d6a;">
  <div style="max-width: 700px; padding:50px 0;  margin: 0px auto; font-size: 14px">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; margin-bottom: 20px">
      <tbody>
        <tr>
          <td style="vertical-align: top; padding-bottom:30px;" align="center"><a href="http://eliteadmin.themedesigner.in" target="_blank"><br/>
            </a> </td>
        </tr>
      </tbody>
    </table>
    <div style="padding: 40px; background: #fff;">
      <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
        <tbody>
          <tr>
            <td><b>Dear Sir/Madam/Customer</b>
              <p>This is to inform you that, Your account with Elite Admin has been created successfully. Log it for more details.</p>
              <a href="javascript: void(0);" style="display: inline-block; padding: 11px 30px; margin: 20px 0px 30px; font-size: 15px; color: #fff; background: #00c0c8; border-radius: 60px; text-decoration:none;"> Call to action button </a>
              <p>This email template can be used for Create Account, Change Password, Login Information and other informational things.</p>
              <b>- Thanks (Test)</b> </td>
          </tr>
        </tbody>
      </table>
    </div>
    <div style="text-align: center; font-size: 12px; color: #b2b2b5; margin-top: 20px">
      <p> Ok sender<br>
        <a href="javascript: void(0);" style="color: #b2b2b5; text-decoration: underline;">Unsubscribe</a> </p>
    </div>
  </div>
</div>
</body>
</html>';

// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

// Additional headers
$headers[] = 'To: AQ <[email protected]>, SQ <[email protected]>';
$headers[] = 'From: Example Email <[email protected]>';
$headers[] = 'Cc: [email protected]';
$headers[] = 'Bcc: [email protected]';


if(mail($to, $subject, $message, implode("\r\n", $headers))){
  echo 'Mail Sent';

}else{


  echo 'Mail NOT Sent';



exit();

}

with this code I try to send an HTML email but I can not make it send me correctly, now if I change to plain text:

$headers[] = 'Content-type: text/plain; charset=iso-8859-1';

I can send the email only with this format

Use SSMTP on Linux

Any suggestions that I may be doing wrong.

Thank you.

    
asked by Alexander Quiroz 02.02.2018 в 02:52
source

1 answer

0

Thanks to @Davlio for his guidance, I could realize that the problem lies in the images and his path I must make the path, which must be with a url, after removing these images to perform a test on the html complete in its original version I was able to send it without problems.

    
answered by 02.02.2018 / 06:37
source