Guys i am now working with php mailer library.i have some errors related to mail()
functions.
This my source code
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.google.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'venki14101996#gmail.com'; // SMTP username
$mail->Password = '8903273610'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'venki14101996#gmail.com';
$mail->FromName = 'VENKAT';
$mail->AddAddress('venkat14101996#gmail.com', 'Josh Adams'); // Add a recipient
$mail->AddAddress('rishi27052001#gmail.com'); // Name is optional
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$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';
THIS SHOWs ME A ERROR MESSAGE
Message could not be sent.Mailer Error: The following From address failed: venki14101996#gmail.com : Called Mail() without being connected
At before i use this source code before
but i don't have the vendor/autoload file in my phpmailer folder
but i download this file in Github
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
* This uses traditional id & password authentication - look at the gmail_xoauth.phps
* example to see how to use XOAUTH2.
* The IMAP section shows how to save this message to the 'Sent Mail' folder using IMAP commands.
*/
//Import PHPMailer classes into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "username#gmail.com";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('from#example.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto#example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto#example.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
//Section 2: IMAP
//Uncomment these to save your message in the 'Sent Mail' folder.
#if (save_mail($mail)) {
# echo "Message saved!";
#}
}
//Section 2: IMAP
//IMAP commands requires the PHP IMAP Extension, found at: https://php.net/manual/en/imap.setup.php
//Function to call which uses the PHP imap_*() functions to save messages: https://php.net/manual/en/book.imap.php
//You can use imap_getmailboxes($imapStream, '/imap/ssl') to get a list of available folders or labels, this can
//be useful if you are trying to get this working on a non-Gmail IMAP server.
function save_mail($mail)
{
//You can change 'Sent Mail' to any other folder or tag
$path = "{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail";
//Tell your server to open an IMAP connection using the same username and password as you used for SMTP
$imapStream = imap_open($path, $mail->Username, $mail->Password);
$result = imap_append($imapStream, $path, $mail->getSentMIMEMessage());
imap_close($imapStream);
return $result;
}
enter code here
Try adding the below code,
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
Guys I have read many answers on this question but the problem still persists.
The PHPMailer is not sending emails giving the following error.
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Following is the code:
date_default_timezone_set('Etc/UTC');
require 'PHPMailer-master/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
//$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "mail.domain.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port =25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
//Username to use for SMTP authentication
$mail->Username = "mail#mail.com";
//Password to use for SMTP authentication
$mail->Password = "password";
//Set who the message is to be sent from
$mail->setFrom("mail#mail.com","Contact Form");
//Set an alternative reply-to address
$mail->addReplyTo($_POST['user_mail'], $_POST['user_name']);
//Set who the message is to be sent to
$mail->addAddress("mail#mail.com", "Contact Form");
//Set the subject line
$mail->Subject = $_POST['subject'] . " - Contact Form";
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("Message from ". $_POST['user_name']." : <br/>".$_POST['message'] . "<br/> Contact Details : <br/> Email :" . $_POST['user_mail'] . "<br/> Contact Number : " . $_POST['user_number']);
//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "<script>window.location.href='thankyou.html';</script>";
}
I have a project in which I have to send 100-200 mails to users but every mail has different token for each user. I have the email hosted on godaddy.
So I was looking to send email using phpmailer. Below is the script which I am testing but it keeps giving me this error -
SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
<?php
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require 'mailm/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
$mail->DKIM_domain = '127.0.0.1';
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtpout.secureserver.net";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 465;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "itsupport#mysite.ae";
//Password to use for SMTP authentication
$mail->Password = "Mypassword";
$mail->SMTPSecure = 'ssl';
//Set who the message is to be sent from
$mail->setFrom('itsupport#mysite.ae', 'IT Helpdesk');
//Set an alternative reply-to address
//$mail->addReplyTo('replyto#example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('sgajara#gmail.com', 'IT Helpdesk');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//Replace the plain text body with one created manually
$mail->Body = 'This is a plain-text message body';
//Attach an image file
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
This script I have found on a blog.
Any alternatives to this are also welcomed, My purpose is to send 200 emails from my godaddy email account but every email has a separate token which is fetched from the database and then inserted in the mail body and sent to the user.
That is so simple:
You must focus on smtp host, port, ssl...
Change smtp host to: relay-hosting.secureserver.net
And DELETE port and ssl, thats all...
Do not use smtp port and smtp ssl true or false...
var fromAddress = "mailfrom#yourdomain";
// any address where the email will be sending
var toAddress = "mailto#yourdomain";
//Password of your mail address
const string fromPassword = "******";
// Passing the values and make a email formate to display
string subject = TextBox1.Text.ToString();
string body = "From: " + TextBox2.Text + "\n";
body += "Email: " + TextBox3.Text + "\n";
body += "Subject: " + TextBox4.Text + "\n";
body += "Message: \n" + TextBox5.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "relay-hosting.secureserver.net";
**//Warning Delete =>//smtp.Port = 80;**
**//Warning Delete =>//smtp.EnableSsl = false;**
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
You need to modify few configurations mentioned below. let me know if this works or not.
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->ssl = false;
$mail->authentication = false;
I recently setup phpmailer as my SMTP sending script to use for a website I've been working on and it's been nothing but a headache. My setup is IIS, and I'm currently using office365 to send out emails(although I have tried gmail and the results were no faster).I would appreciate any and all advice on how to speed this up, or if there's a way to post to a php file from javascript or php and then just let it work I could do that too. I'm trying to stay away from cron jobs if possible.
my script:
function sendMail($code, $email) {
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtp.office365.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "support#[domain redacted].com";
//Password to use for SMTP authentication
$mail->Password = "[password redacted]";
//enable TLS
$mail->SMTPSecure = 'tls';
//Set who the message is to be sent from
$mail->setFrom('support#[domain redacted].com', '[redacted]');
//Set an alternative reply-to address
$mail->addReplyTo('support#[domain redacted].com', '[redacted]');
//Set who the message is to be sent to
$mail->addAddress($email);
//Set the subject line
$mail->Subject = 'This is a test email from EdTester Support';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->Body = "Hello there, This is your activation e-mail. Please go to: http://[domain redacted]/activate.php?code=". $code . "&email=" . $email;
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
I would like to send an email using Gmail SMTP server through PHP Mailer.
this is my code
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet="UTF-8";
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = 'MyUsername#gmail.com';
$mail->Password = 'valid password';
$mail->SMTPAuth = true;
$mail->From = 'MyUsername#gmail.com';
$mail->FromName = 'Mohammad Masoudian';
$mail->AddAddress('anotherValidGmail#gmail.com');
$mail->AddReplyTo('phoenixd110#gmail.com', 'Information');
$mail->IsHTML(true);
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = "Hello";
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
?>
but I receive this following error
Mailer Error: SMTP Error: The following recipients failed: anotherValidGmail#gmail.com
SMTP server error: SMTP AUTH is required for message submission on port 587
my domain is vatandesign.ir
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "email#gmail.com";
$mail->Password = "password";
$mail->SetFrom("example#gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("email#gmail.com");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
This code above has been tested and worked for me.
It could be that you needed $mail->SMTPSecure = 'ssl';
Also make sure you don't have two step verification switched on for that account as that can cause problems also.
UPDATED
You could try changing $mail->SMTP to:
$mail->SMTPSecure = 'tls';
It's worth noting that some SMTP servers block connections.
Some SMTP servers don't support SSL (or TLS) connections.
So I just solved my own "SMTP connection failure" error and I wanted to post the solution just in case it helps anyone else.
I used the EXACT code given in the PHPMailer example gmail.phps file. It worked simply while I was using MAMP and then I got the SMTP connection error once I moved it on to my personal server.
All of the Stack Overflow answers I read, and all of the troubleshooting documentation from PHPMailer said that it wasn't an issue with PHPMailer. That it was a settings issue on the server side. I tried different ports (587, 465, 25), I tried 'SSL' and 'TLS' encryption. I checked that openssl was enabled in my php.ini file. I checked that there wasn't a firewall issue. Everything checked out, and still nothing.
The solution was that I had to remove this line:
$mail->isSMTP();
Now it all works. I don't know why, but it works. The rest of my code is copied and pasted from the PHPMailer example file.
Also worth noting that if you have two factor authentication enabled, you'll need to setup an application specific password to use in place of your email account's password.
You can generate an application specific password by following these instructions:
https://support.google.com/accounts/answer/185833
Then set $mail->Password to your application specific password.
It seems that your server fails to establish a connection to Gmail SMTP server.
Here are some hints to troubleshoot this:
1) check if SSL correctly configured on your PHP (module that handle it isn't installed by default on PHP. You have to check your configuration in phph.ini).
2) check if your firewall let outgoing calls to the required port (here 465 or 587). Use telnet to do so. If the port isn't opened, you'll then require some support from sysdmin to setup the config.
I hope you'll sort this out quickly!
Google treat Gmail accounts differently depending on the available user information, probably to curb spammers.
I couldn't use SMTP until I did the phone verification. Made another account to double check and I was able to confirm it.
this code working fine for me
$mail = new PHPMailer;
//Enable SMTP debugging.
$mail->SMTPDebug = 0;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = $hostname;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = $sender;
$mail->Password = $mail_password;
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "ssl";
//Set TCP port to connect to
$mail->Port = 465;
$mail->From = $sender;
$mail->FromName = $sender_name;
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $Subject;
$mail->Body = $Body;
$mail->AltBody = "This is the plain text version of the email content";
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo 'Mail Sent Successfully';
}
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
If you are using cPanel you should just click the wee box that allows you to send to external servers by SMTP.
Login to CPanel > Tweak Settings > All> "Restrict outgoing SMTP to
root, exim, and mailman (FKA SMTP Tweak)"
As answered here:
"Password not accepted from server: 535 Incorrect authentication data" when sending with GMail and phpMailer
Anderscc has got it correct. Thanks. It worked for me but not 100%.
I had to set
$mail->SMTPDebug = 0;
Setting it to 1, can cause errors especially if you are passing some data as json to next page. Example - Performing verification if mail is sent, using json to pass data through ajax.
I had to lower my gmail account security settings to get rid of errors:
" SMTP connect() failed " and " SMTP ERROR: Password command failed "
Solution:
This problem can be caused by either 'less secure' applications trying to use the email account (this is according to google help, not sure how they judge what is secure and what is not) OR if you are trying to login several time in a row OR if you change countries (for example use VPN, move code to different server or actually try to login from different part of the world).
Links that fix the problem (you must be logged into google account):
view recent attempts to use the account and accept suspicious access.
link to disable the feature of blocking suspicious apps/technologies:
https://www.google.com/settings/u/1/security/lesssecureapps
Note:
You can go to the following stackoverflow answer link for more detailed reference.
https://stackoverflow.com/a/25175234
I have found a solution and it is working.
Basic settings:
$mail->IsHTML(true);
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
//SMTP::DEBUG_OFF = off (for production use)
//SMTP::DEBUG_CLIENT = client messages
//SMTP::DEBUG_SERVER = client and server messages
$mail->SMTPDebug = SMTP::DEBUG_CLIENT;
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = 'user#gmail.com';
//Password to use for SMTP authentication
$mail->Password = 'PASSWORD_HERE';
//Set who the message is to be sent from
$mail->setFrom('email#email.ext', 'From where it is sent');
//Set an alternative reply-to address
$mail->addReplyTo('email#email.ext', 'Reply To');
//Set who the message is to be sent to
$mail->addAddress('email#email.ext');
//Set the subject line
$mail->Subject = 'Email subject';
// Body message
$mail->Body = '
<h1>Message details</h1>
';
// Send message
if( $mail->send() ) {
echo "Sent"
} else {
echo "Not Sent";
}
If you've already tried everything, try doing this:
Disable the feature of blocking suspicious apps/technologies https://www.google.com/settings/u/1/security/lesssecureapps
Clear the Captcha https://accounts.google.com/b/0/DisplayUnlockCaptcha
Do the test.
Here are some articles of interest that helped me solve this:
https://support.google.com/a/thread/108782439/smtp-error-password-command-failed-535-5-7-8-username-and-password-not-accepted?hl=en&msgid=108963583
https://bobcares.com/blog/phpmailer-smtp-error-password-command-failed/
I just wanted to share my experience with phpMailer , that was working locally (XAMPP) but wasn't working on my hosting provider.
I turned on phpMailer error reporting
$mail->SMTPDebug=2
I got 'Connection refused Error'
I email my host provider for the issue, and they said that they would open the SMTP PORTS 25, 465, 587.
Then I got the following error response "SMTP ERROR: Password command failed:"...."Please log in via your web browser and then try again"...."SMTP Error: Could not authenticate."
So google checks if your are logged in to your account (I was when I ran the script locally through my browser) and then allows you to send mail through the phpMailer script.
To fix that:
1: go to your Google account -> security
2: Scroll to the Key Icon and choose "2 way verification" and follow the procedure
3: When done go back to the key icon from google account -> security and choose the second option "create app passwords" and follow the procedure to get the password.
Now go to your phpMailer object and change your Google password with the password given from the above procedure.
You are done.
The code:
require_once('class.phpmailer.php');
$phpMailerObj= new PHPMailer();
$phpMailerObj->isSMTP();
$phpMailerObj->SMTPDebug = 0;
$phpMailerObj->Debugoutput = 'html';
$phpMailerObj->Host = 'smtp.gmail.com';
$phpMailerObj->Port = 587;
$phpMailerObj->SMTPSecure = 'tls';
$phpMailerObj->SMTPAuth = true;
$phpMailerObj->Username = "YOUR EMAIL";
$phpMailerObj->Password = "THE NEW PASSWORD FROM GOOGLE ";
$phpMailerObj->setFrom('YOUR EMAIL ADDRESS', 'THE NAME OF THE SENDER',0);
$phpMailerObj->addAddress('RECEIVER EMAIL ADDRESS', 'RECEIVER NAME');
$phpMailerObj->Subject = 'SUBJECT';
$phpMailerObj->Body ='MESSAGE';
if (!phpMailerObj->send()) {
echo "phpMailerObjer Error: " . $phpMailerObj->ErrorInfo;
return 0;
} else {
echo "Message sent!";
return 1;
}
If anyone there who is not getting a working answer, they can try this.
Note: I am using PHPMailer 5.2.23.
<?php
date_default_timezone_set('Asia/Kolkata');
require './Libraries/PHPMailer5/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
// Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'localhost';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "yourWebmailUsermail";
$mail->Password = "yourWebmailPassword";
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setFrom('formEmailAddress', 'First Last');
$mail->addAddress('toEmailAddress', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->msgHTML("<h1>Hi Test Mail</h1>");
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
I think it is connection issue you can get code here http://skillrow.com/sending-mail-using-smtp-and-php/
include(“smtpfile.php“);
include(“saslfile.php“); // for SASL authentication $from=”my#website.com“; //from mail id
$smtp=new smtp_class;
$smtp->host_name=”www.abc.com“; // name of host
$smtp->host_port=25;//port of host
$smtp->timeout=10;
$smtp->data_timeout=0;
$smtp->debug=1;
$smtp->html_debug=1;
$smtp->pop3_auth_host=””;
$smtp->ssl=0;
$smtp->start_tls=0;
$smtp->localhost=”localhost“;
$smtp->direct_delivery=0;
$smtp->user=”smtp username”;
$smtp->realm=””;
$smtp->password=”smtp password“;
$smtp->workstation=””;
$smtp->authentication_mechanism=””;
$mail=$smtp->SendMessage($from,array($to),array(“From:$from”,”To: $to”,”Subject: $subject”,”Date: ”.strftime(“%a, %d %b %Y %H:%M:%S %Z”)),”$message”);
if($mail){
echo “Mail sent“;
}else{
echo $smtp->error;
}