home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for how to send email in php
1<?php
2$to = 'user@example.com';
3$subject = "Send HTML Email Using PHP";
4
5$htmlContent = '
6<html>
7<body>
8    <h1>Send HTML Email Using PHP</h1>
9    <p>This is a HTMl email using PHP by CodexWorld</p>
10</body>
11</html>';
12
13// Set content-type header for sending HTML email
14$headers = "MIME-Version: 1.0" . "\r\n";
15$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
16
17// Additional headers
18$headers .= 'From: CodexWorld<info@codexworld.com>' . "\r\n";
19$headers .= 'Cc: welcome@example.com' . "\r\n";
20$headers .= 'Bcc: welcome2@example.com' . "\r\n";
21
22// Send email
23if(mail($to,$subject,$htmlContent,$headers)):
24    $successMsg = 'Email has sent successfully.';
25else:
26    $errorMsg = 'Email sending fail.';
27endif;
28?>
29
upvote
downvote
source