How to send yahoo email using smtp server by php.You can send yahoo email using PHPMailer package.Simply pass parameters.
You can Download PHPMailer from here.
If you execute this function in localhost, you must enable “php_openssl” extension of the wamp/xampp.
From = $FromEmail; $mail->FromName = $FromName; $mail->IsSMTP(); $mail->SMTPAuth = true; // turn of SMTP authentication $mail->Username = "YAHOO EMAIL ADDRESS"; // SMTP username (Ex: [email protected]) $mail->Password = "YAHOO EMAIL ADDRESS PASSWORD"; // SMTP password (Ex: yahoo email password) $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.mail.yahoo.com"; $mail->Port = 465; $mail->SMTPDebug = 2; // Enables SMTP debug information (for testing, remove this line on production mode) // 1 = errors and messages // 2 = messages only $mail->Sender = $FromEmail;// $bounce_email; $mail->ConfirmReadingTo = $FromEmail; $mail->AddReplyTo($FromEmail); $mail->IsHTML(true); //turn on to send html email $mail->Subject = $Subject; $mail->Body = $Message; $mail->AltBody = "ALTERNATIVE MESSAGE FOR TEXT WEB BROWSER LIKE SQUIRRELMAIL"; $mail->AddAddress($ToEmail,$ToEmail); if($mail->Send()){ $mail->ClearAddresses(); } } $FromEmail = 'FROM EMAIL ADDRESS HERE'; //[email protected] $Subject = 'EMAIL SUBJECT HERE'; $Message = 'EMAIL MESSAGE CONTENTS HERE'; $FromName = 'FROM NAME'; // Sumith Harshan $ToEmail = 'TO EMAIL ADDRESS'; //[email protected] $response = sendEmail($FromEmail,$Subject,$Message,$FromName,$ToEmail); print_r($response); ?>
Final result is like this.
SMTP -> FROM SERVER:220 smtp216.mail.ne1.yahoo.com ESMTP
SMTP -> FROM SERVER: 250-smtp216.mail.ne1.yahoo.com 250-AUTH LOGIN PLAIN XYMCOOKIE 250-PIPELINING 250-SIZE 41697280 250 8BITMIME
SMTP -> FROM SERVER:250 OK , completed
SMTP -> FROM SERVER:250 OK , completed
SMTP -> FROM SERVER:354 Start Mail. End with CRLF.CRLF
SMTP -> FROM SERVER:250 OK , completed
Download PHP send yahoo email using smtp Example (50 KB)