How to send from yahoo mail in php using xampp
To send an email from Yahoo Mail using PHP and XAMPP, you'll need to use the PHPMailer library, which is a popular and widely-used library for sending emails in PHP. Here's a step-by-step guide to help you get started:
Step 1: Install PHPMailer
Download the PHPMailer library from the official website: https://github.com/PHPMailer/PHPMailer
Extract the downloaded zip file to a directory on your XAMPP server, for example, C:\xampp\htdocs\PHPMailer
.
Step 2: Configure PHPMailer
Create a new PHP file, for example, send_email.php
, in the same directory as the PHPMailer library. Add the following code to the file:
<?php
require_once 'PHPMailer/PHPMailer.php';
require_once 'PHPMailer/SMTP.php';
require_once 'PHPMailer/Exception.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.mail.yahoo.com';
$mail->SMTPAuth = true;
$mail->Username = 'your_yahoo_email_address';
$mail->Password = 'your_yahoo_email_password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('your_yahoo_email_address', 'Your Name');
$mail->addAddress('recipient_email_address', 'Recipient Name');
$mail->Subject = 'Test Email from Yahoo Mail using PHPMailer';
$mail->Body = 'This is a test email sent from Yahoo Mail using PHPMailer';
if (!$mail->send()) {
echo 'Error sending email: '. $mail->ErrorInfo;
} else {
echo 'Email sent successfully!';
}
?>
Replace the placeholders with your actual Yahoo email address, password, and recipient email address.
Step 3: Test the script
Open a web browser and navigate to http://localhost/send_email.php
(assuming you're using XAMPP's default Apache server). If everything is set up correctly, you should see the email sent successfully message.
Note: Make sure to enable the allow_call_time_pass_reference
directive in your php.ini
file, as it's required for PHPMailer to work correctly. You can do this by adding the following line to your php.ini
file:
allow_call_time_pass_reference = On
Restart your XAMPP server after making this change.
That's it! You should now be able to send emails from Yahoo Mail using PHP and XAMPP.