简体   繁体   中英

unable to send mail from server usiong php mail in html format

i am trying to send mail using php mail function it works good with below code:

<?php
$to = "abhwebdesign@gmail.com";
$subject = "subject";
$password="xxxxx";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body >
<div style='width:670px;height:450px;padding:50px;background-color:#EFEFEB;'>
<div style='width:600px;height:450px;background-color:#FFFFFF;color:#105b94;font-size:20px;padding:10px'>
<img src='http://www.example.com/Images/Index/Logo.png' />
<p>Hi,</p>
<table style='color:#105b94;font-size:20px;'>
<tr>
<td><p>Thank you for registering with us.</p></td>
</tr>
<tr>
<td><br>Your password is :$password<br><br>We appreciate your interest.
</td>
</tr>
<tr>
<td><hr>Contact Us <br>Office :9999999999<br>www.example.com
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: Support <support@example.com>' . "\r\n";


mail($to,$subject,$message,$headers);
?>

the code works good if i remove www.example.com from above code in the line " Office :9999999999
www.example.com " please help me.

I strongly recommend you to use: http://swiftmailer.org/

This includes mail headers and configurations. It manages all that stuff you don't want to see.

Kind regards!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM