<?php
$to = "rajesh.bakade65@gmail.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <rajesh.bakade@chpl.tv>' . "\r\n";
//$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
and my php.ini file is
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
plz suggest any solution so that i will be able to send mail from localhost
Thanks
require_once 'lib/swift_required.php';
[1]: http://i.stack.imgur.com/t3Pbc.jpg
Use the feature-rich SwiftMailer and your settings should be like this:
Here is how you can set your credentials and send the email.
You seem to be using the wrong port number for
smtp_port
: when looking at the GMail settings, it looks like you'd need port587
or465
. (Depending whether you want to use TLS or SSL encryption)Furthermore I do not know whether PHP support SSL and/or TLS. If not you need to use an additional PHP library in order to be able to connection to the Google mail server.