Sending E-mails in php using yahoo smtp
<?php
require 'Mail/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'plus.smtp.mail.yahoo.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'yourname@yahoo.com'; // SMTP username
$mail->Password = 'xxxxxxxxxxxxxxxxxxxxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl', 'tls' etc...
$mail->Port = 465; // or 587
$mail->Timeout = 5 * 60; // Message sent timeout
$mail->From = 'yourname@yahoo.com';
$mail->FromName = 'Pritom Kumar Mondal';
// Add a recipient
$mail->AddAddress('yourname@gmail.com', 'Pritom GMAIL');
$mail->AddAddress('yourname@yahoo.com', 'Pritom YAHOO');
$mail->AddReplyTo('yourname@gmail.com', 'Reply To');
$mail->AddCC('yourname@gmail.com');
$mail->AddBCC('yourname@gmail.com');
$mail->WordWrap = 50; // Set word wrap to 50 characters
// Add attachments
$mail->AddAttachment('C:\\Contact List.csv', 'pritom.csv'); // Optional name
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'E-mail sent using yahoo smtp';
$mail->Body = 'This is the HTML message body <b>in bold!</b>, sent using yahoo smtp';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if (!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';?>
No comments:
Post a Comment