-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message could not be sent.Mailer Error: SMTP connect() failed. #469
Comments
That link should be https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting - I'm not sure where the "Available" came from. As the guide says, in pretty much every case this is nothing to do with PHPMailer, but the network config on your server or ISP. Setting The |
thank you so much Synchro for your precious feedback . isMail() working perfectly. but i dnt knw y isSMTP is still giving some error, which i dont understand at all
My coding <?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = [email protected]';
$mail->FromName = 'Mailer';
//$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$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;
} else {
echo 'Message has been sent';
}
?> |
Synchro sorry, i didnt mentioned that the bold values in error message, keeps on changing each time i refresh my page... |
That bold value is just a link tracking ID, it will end up in the same place. So it just looks like your username or password is not correct. |
That transcript looks like you have |
dear synchro. thanks for your reply. but got some issues. <?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$file = $_FILES['attachment']['tmp_name'];
$message = $_POST['message'];
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isMail(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = '[email protected]';
$mail->FromName = $name;
//$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'SASP Contact Form';
$mail->Body = $message;
$mail->Body .= "<br /><br />Below are my contact details <br /> Name: ";
$mail->Body .= $name;
$mail->Body .= "<br />My Phone number: ";
$mail->Body .= $phone;
$mail->Body .= "<br /> My email address: ";
$mail->Body .= $email;
$mail->AltBody = 'You are using basic web browser ';
if(is_array($_FILES)) {
$mail->AddAttachment($_FILES['attachment']['tmp_name'],$_FILES['attachment']['name']);
}
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
//echo 'Message has been sent';
header('Location: thankyou.html');
}
?>
Message could not be sent.Mailer Error: Could not instantiate mail function. |
Solve one problem at a time. Your code for handling attachments is wrong - look at the examples folder for how to do that properly, but solve your connection problem first. |
thank u fr the replay.. |
"Could not instantiate mail function" usually means you have no local mail server, so check that you have one. In your php.ini file you should have a setting for sendmail_path, and that program must exist. If you can't change that, or it doesn't exist, contact your hosting provider. When you say "it's working perfectly", do you mean that the script runs and you receive the sent message? |
yes. when i use isMail(). i receive message perfectly. only when the recipient mail is [email protected] but when i change the $mail->addAddress('[email protected]'); to $mail->addAddress('[email protected]');. with rest of the code untouched, i get "Could not instantiate mail function" |
How about you read the docs the error message links you to?
|
its show on my page |
how can i solve my error
|
Read the docs, like I told you.
|
Dear brother(synchro) |
this is my code <?php
require('phpmailer/class.phpmailer.php');
$mail = new PHPMailer;
$name = 'name';
$phone = 'phone';
$email = 'email';
$message = 'HI Friends How are you';
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isMail(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 486; // TCP port to connect to
$mail->From = '[email protected]';
$mail->FromName = $name;
//$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'SASP Contact Form';
$mail->Body = $message;
$mail->Body .= "<br /><br />Below are my contact details <br /> Name: ";
$mail->Body .= $name;
$mail->Body .= "<br />My Phone number: ";
$mail->Body .= $phone;
$mail->Body .= "<br /> My email address: ";
$mail->Body .= $email;
$mail->AltBody = 'You are using basic web browser ';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?> |
@Mozammelctgmirbd: Read before posting, don't hijack old threads. You are using an old version of PHPMailer and have not read the docs. You've made up apparently random settings and you're wondering why it doesn't work. It's very likely that you need to say |
Dear Brother |
sendmail.inc i change flowing this [sendmail] smtp_server=smtp.gmail.com |
you told me that for change $mail->Port = 465;. |
i dont undestand.please help me |
Sendmail settings have no effect because you're using SMTP - again, changing random settings will not help. Messages will be sent to your gmail address, but you really need to read the docs. |
Dear Brother |
There's not much point in me trying to help you if you don't read what I say. Also, don't post your passwords - this is a public forum. |
sorry my dear Brother |
you are helper so that i know about you |
Dear Brother |
please help me |
Dear broth (Synchro) |
I don't know how I can make this any clearer: read the docs. |
ok dear you say i want to see message. which mail this message will be store |
[email protected] or [email protected] ------------------which--???? |
please please please |
not online from any site |
It will send to |
hi, i'm new to php and i have been trying to send e-mail through php, phpmailer is the only class i find most recommended by most of the developers. i tried almost all solutions for my error. i cant find the fix. I have tried the link below, but didn't get what to do, and googled for the solution, couldn't find any, which works for me. tried almost all solutions, but it keeps showing me the same error.
Message could not be sent.Mailer Error:SMTP connect() failed.https://github.com/PHPMailer/PHPMailer/wiki/TroubleshootingAvailable
tried the above link, as im new to php, im stuck.
fr all smtpdebug: 1,2,3,4, its giving same error... but php mail() function is working fine.
and our hosting provider says this...
We have the following list of ports open on our shared hosting plans:
HTTP/HTTPS - 80/443
GMail - 465/587/995/993
TOMCAT - 8080
SMTP/IMAP/POP - 25/143/110
here is the code im using. please help me to resolve the error. thanx in advance.
The text was updated successfully, but these errors were encountered: