Send Mail Without SMTP Authentication
Welcome Back to Shortlearner.com, today we will see how to send mail without SMTP Authentication .
First of all we should know about overall funcationality of SMTP.
in the basic words we can say SMTP is Simple Mail Transfer Protocol, and it defines the method that handles the process of email exchange and delivery across IPs.
In our Previous Post we send mail with SMTP Authentication.
Also Read : Read XML file Using Php
Track vistior location of your website
Build a Facebook messenger chatbot using php
Generate Random Password Using php
SMTP communication between mail servers uses TCP port 25.
Most of the time we use Phpmailer for sending emails. Initially it was works fine when we using SMTP by username and password.
In the below code we send mail without SMTP Authentication
<?php require 'class/class.phpmailer.php'; $mail = new PHPMailer; $mail->setFrom('xxxx@domainname.com', 'First Last'); $mail->addAddress("xxxx@domainname.com", "Recepient Name"); $mail->addReplyTo("xxxx@domainname.com", "Reply"); $mail->isHTML(true); $mail->Subject = "Subject Text"; $mail->Body = "<i>Welcome To Shortlearner</i>"; $mail->AltBody = "This is the plain text version of the email content"; if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent successfully"; } ?>