4 | Paste this code and change the values in blue as you need (I modified the sample code given on the PHPMailer homepage)
require("phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP IsSMTP(); // send via SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "username@gmail.com"; // SMTP username $mail->Password = "password"; // SMTP password $webmaster_email = "username@doamin.com"; //Reply to this email ID $email="username@domain.com"; // Recipients email ID $name="name"; // Recipient's name $mail->From = $webmaster_email; $mail->FromName = "Webmaster"; $mail->AddAddress($email,$name); $mail->AddReplyTo($webmaster_email,"Webmaster"); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment $mail->IsHTML(true); // send as HTML $mail->Subject = "This is the subject"; $mail->Body = "Hi, This is the HTML BODY "; //HTML Body $mail->AltBody = "This is the body when user views in plain text format"; //Text Body if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?> |
198 Comments:
hello
I have tried to work out the procedure mentioned but i get a timeout.....can u please help?
Check your internet
Check whether you have your firewall setting
If you are in a LAN with firewall blocking the port then you will get this error
yes i have a firewall....how do i give access privileges to this port....i use mcafee wirewall what are the settings i need to do....plese help....
Gmail requires you to use SSL authentication, a further step is required if you don't already have php configured for this:
1. open your php.ini file, and find the windows extensions part. Now uncomment the extension=php_openssl.dll.
2. Save the php.ini file and restart your server.
3.Try running your php again, it should send the mail.
Note: My script successfully sent the email (I recieved it in my test inbox) but the php script returned a warning:
"Warning: fgets() [function.fgets]: SSL: fatal protocol error in PathToPhpIncludes\class.smtp.php on line 1027"
First, let me say that this is the best fix I've seen for sending SMTP autheticated email through GMAIL...and I've tried a bunch of things. It works well...but there's still one problem...I got the same error as the post above:
Warning: fgets() [function.fgets]: SSL: fatal protocol error in C:\wamp\www\phpmailer\class.smtp.php on line 1027
Does anyone know why this might be happening, and how I can get rid of it?
Hi,
DOes anyone read this blog? If so, can someone please help answer the question in the last comment?
Thanks,
E
On a forum post I found a suggestion:
3. change to fgets() to @fgets() to surpass the ssl error
Hey...thanx. @fgets() works
Hi there
I set up a server at my desktop, then get this error.... No clue...
Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in F:\livingProgrammes\wamp5\www\test_phpmailer\class.smtp.php on line 110
Hi Figo2476,
1. uncomment the extension=php_openssl.dll in php.ini
2. Check the port used for SSL
Wouldn't you need to use 587 and TLS, not 465 and ssl?
Great article! Thanks.
Nice Blog!
Awesome. It really works. First working solution i've seen...
Btw, for those who didn't realize: in his sample code, he left out the fact that you need to include PHPMailer, and these 2 lines:
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in c:\wamp\www\mail1\class.smtp.php on line 106
Mailer Error: Language string failed to load: connect_host
hey this is the error that it shows when i try to run this script....can any body help in this matter....
IT's work perfect, thanks!!!!!!!!!!!!!!!!!!!!
Excellent website. Good work. Very useful. I will bookmark!
Bless you. I've spent days trying to get the phpmailer built into Wordpress 2.2 to play nice. When I saw how simple the solution was, I nearly cried. Thanks.
I use NuSphere PHP ED, I had to do the following changes to make it work:
In file: email.php my top 4 lines are:
include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP();
Uncomment the following in PHP.ini
extension=php_openssl.dll
Hi all,
Can anyone tell me how to telnet to gmail smtp server (from windows)?
Fatal error: Call to undefined function IsSMTP() in /home/www/liveonrent/htdocs/smtp/phpmailer/test2.php on line 7
Replace the first line of the above code :-
IsSMTP(); // send via SMTP
with this :-
include("class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
It works fine now !
Thanks for the example.
I followed the instructions of editing php.ini file and creating a new email.php file.. but getting the following error
----------------------
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in E:\wamp\www\phpmailer\class.smtp.php on line 106
Mailer Error: SMTP Error: Could not connect to SMTP host.
I just set up Google Apps for my domain and wrote a blog post on my experience. You can learn more about maximizing email deliverability using SPF records and Sender ID.
Tutorial: Sending email through Gmail
SMTP with authentication (using GMAIL and PHPMAILER):
Note: I used the classes from http://www.buayacorp.com/files/php/gmail-phpmailer.zip
But I had changed all the code from test.php to the one above.
1) I've got the classes class.phpmailer, class.smtp.php and test.php at the same directory
---------------TEST.php--------
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "username@doamin.com"; //Reply to this email ID
$email="username@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
-----------------------
At class.smtp.php
before line 104 (before #connect), use this lines:
$host = "ssl://smtp.gmail.com"; $port = 465;
-----------------------
In the PHP.ini, you need to have this option:
extension=php_openssl.dll
Then, restart your server (wamp/apache/other).
----------------
Change your test.php with your own information... and VOILÁ... it works! It worked for me, and I ad tried a million stuffs before.. lol
PS: Sorry the crappy english. For any help, contact: sol_lunar at iol.pt
Thanks,
Mivla.
KRANTI:
E:\wamp\www\phpmailer\class.smtp.php on line
-----------
solution:
If you are using localhost, whereas, "wamp", please upload the files
to the live server in order to work
properly... unless,,, you have
configured your local server
to have a smtp connection...
Warning: fsockopen(): no SSL support in this build in C:\apache2triad\htdocs\mailtest\class.smtp.php on line 123 Warning: fsockopen(): unable to connect to smtp.gmail.com:465 in C:\apache2triad\htdocs\mailtest\class.smtp.php on line 123 Mailer Error: SMTP Error: Could not connect to SMTP host
***in server ssl configurations done successfully. So please help me.
Omg, thewebcammaster, people like you and the developers of the class should all get handjobs from the open source community. I've been searching 3 hours for a way to get email through php done correctly. Now because of this article and xpertmailer, I will be able to take one step closer to world domination.
Hey, i've got error on this
============================
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\dlpd\trial\mail\PHPMailer\class.smtp.php on line 125
============================
why is this??
Thanks, probably the simplest fix I have seen.
-Bhagyesh
Mailer Error: SMTP Error: Could not connect to SMTP host.
Please help me....i don't what to do.
To all the people with the same SSL authentication error. Of course you probably won't see this because you obviously do not read comments before you post them. There is already a solution people. If you do a little reading and pay attention you will figure stuff out.
Thanks! Your instructions are spot on. I've been trying to configure gmail for a long time.
i can`t use gmail, then i try with other server, and work!!!
The problem is ssl authentication.
Try to use a server without ssl, another that use port 25.
regards!!!
Worked a charm thanks mate. I also had to uncomment the following line from my php.ini
extension=php_openssl.dll
but I think that's because I'm on windows
Hi guys, Why I get that error?
Mailer Error: Language string failed to load: connect_host
I don't have my own server...
I pay 20 euro por year for a Windows server... ( Aruba ).
For that reason I can't change the file: php.ini
Anyway i think there something wrong... Maybe because my gmail in in italian? Or maybe because the operating system of the server of Aruba is in italian?
I really don't know...
Please help...
Thanks again to everybody...
Samu
can you do this with uploading it to your web server?
I put that code in class.smtp.php before #connect to the smtp server, (which was not at line 104 in dreamweaver) and uploaded it and when I ran the program, I got
Parse error: parse error, unexpected T_VARIABLE in /home/www/jonathonbaker.com/class.smtp.php on line 122
PhpMailer Settings to Send email using PHP with Gmail
Good. it worked perfectly
thank u soooooooo much for the tip..i've been stuck on this problem for a whole week n finally came across this site n figured it out....the only thing i'm concerned with is, is it possible to send to multiple recipients with php mailer?
thanks again!
Could not connect to SMTP host. ?>
didnt work what need to do?
Finally! Had problems for days until i tried this. Thx!
One problem thou. The mail recipient treats the mail as spam and puts it in the spambox...
this also works for yahoo.. thanks
Hi,
Thank you for the script !
I was searching for a such script for many weeks !
Thank you again !
i am getting the error same as Kranti...
is any configuration required in httpd.conf or /extra/httpd-ssl.conf ??
Tanks in advance...
I found this class pathetic...
hi,i can't find the #connect statement in class.smtp.php file,can you please help me where am i going wrong..
thanks :)
OOh yes...it went just OK!!
I didn't notice when was the 1'st post written, but now , we are in 7-11-2008 ,and I found it very very useful
Thank you every body
I wish you all the best!
Salam
hi ,
i got this exception while sending mail
fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in D:\wamp\www\drupal\class.smtp.php on line 122.
include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "xxx@gmail.com"; // SMTP username
$mail->Password = "xxx"; // SMTP password
$webmaster_email = "xxx@gmail.com"; //Reply to this email ID
$email="xxx@xxx.com"; // Recipients email ID
$name="xxx"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body"
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
hi i'm using this code but i got an exception
unable to connect to ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in D:\wamp\www\drupal\class.smtp.php on line 122.
include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "webmaster@xxx.com"; // SMTP username
$mail->Password = "xxxx"; // SMTP password
$webmaster_email = "webmaster@xxx.com"; //Reply to this email ID
$email="xxx@xxx.com"; // Recipients email ID
$name="xxx"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
mine works but returns an 500 internal server error if it is successfull. help!
you are so beatuful for meeeeeeeee
lol
you are great thank you
For those who use Windows environments, this also seems to work:
http://digiex.net/guides-tutorials/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html
Payday loans come in handy when you are in need of a short term loan!
I must thank you....
Its really working but
Replace first line with
include("class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP
Chathura Sri Lanka
Wow! thanks.
I also got fsockopen error.
I was behind a proxy and the error went away when I directly connected my PC to the Internet.
Great script, thanks again :)
i am gettin gthe same comment. its fine when submitting to the database, it just wont send the email across.
i am not using gmail at all. so i dont think that uncommenting line relates to me. i am using an IIS tho that requires a username and password. i am still gettin gthat same error of not being able to connect to the smtp host. i am sure i am inputting the right smtp address tho. am using port 25 as well
Hi!!
This is perfect!!
But don't have to modify the file class.smtp.php:
u can use this:
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->Mailer = "smtp";
Bye
This also good one
http://heidisoft.com/blog/gmail-php-send-email-using-php-gmail
@kranti
I'm facing similar problem.with same errors. fsockopen error can be removed by enabling php_sockets and php_openssl
I'm not able to figure out the second error. "Mailer Error: SMTP Error: Could not connect to SMTP host." .
please help me out with this i've tried this on many servers.
Thank you, it works very fine.
It costed me a lot of time searching before I found your blog. Again, thank you very much ^.^
I used this code, it is working fine.
Thanks a lot for sharing this information.
This is good explanation but it does assume your default SMTP server is/will be gmail and that these values are the defaults PHP will pick up from your phpmailer config ie ssl://smtp.gamil.com:465
The phpmailer class supports properties for setting Host, but any attempt to set the 'Host' property in your script to the necessary values will fail
ie
$mail->Host = "ssl://smtp.gmail.com:465";
will fail by default. This is really because the class wasn't written with GMail in mind.
The phpmailer class parses the host string looking for instances of the character ':' so as to separate SMTP server addresses from related ports. The gotcha with the google SMTP server is that the fully qualified notation 'ssl://smtp.google.com:465' causes the phpmailer SMTP connection parsing algorithm to fail - ie there are two instances of ':' in 'ssl://smtp.google.com:465', phpmailer expects only the second one.
My fix was to edit my copy of class.phpmailer.php, and change part of the code in the SmtpConnect function where the problem is.
from
if(strstr($hosts[$index], ":"))
list($host, $port) = explode(":", $hosts[$index]);
else{
$host = $hosts[$index];
$port = $this->Port;
}
to
if(strstr($hosts[$index], "::"))
list($host, $port) = explode("::", $hosts[$index]);
else{
$host = $hosts[$index];
$port = $this->Port;
}
I can then send email via SMTP without having to change the PHP defaults, using the phpmailer properties/functions as intended
$mail = new PHPMailer();
$mail->SetLanguage( 'en', '/usr/share/php/libphp-phpmailer/language' );
$mail->Host = "ssl://smtp.gmail.com::465";
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "gmail_user_name@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "martinwalker@gmail.com"; //Reply to this email ID
$email="an_email@hotmail.com"; // Recipients email ID
$name="to name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "from name";
$mail->Subject="Charlie says ....";
$mail->AddAddress($email,$name);
etc, etc
Note : I can now use
$mail->Host="ssl://smtp.gmail.com::465";
(note particularly '::' followed by port)
This fix leaves me free to decide how I send email in my code - the gotcha is that if I use any SMTP server, and specify the full string, I will need to use '::' followed by the port number.
Don't try this if it doesn't make perfect sense, keep a copy of your original class.phpmailer.php file just in case you go off course and need to return to you original set up.
MW
I get this error. "SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host. " I already put this:
include "class.phpmailer.php";
include "class.smtp.php";
$mail=new PHPMailer();
Please help me to fix it?
anybody can help this problem.
Warning: fsockopen() [function.fsockopen]: unable to connect to http://smtp.gmail.com:465 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\chris\v17\class.smtp.php on line 122
Mailer Error: SMTP Error: Could not connect to SMTP host.
Can we retrieve mails in PHP
Hello,
It works perfectly !
Just edit your php.ini and uncomment the openssl.dll.
Next, just copy the 3 class files in your work directory.
After that create an object PHPMailer() by including("class.phpmailer.php") in your php file.
Very easy with phpmailer,
Thank you for this topic.
Regards,
Steo 6 is wrong:
Paste this code
$host = "ssl://smtp.gmail.com";
$port = 465;
before the line 104 #connect to the smtp server
Hint: Search for #connect
You should be using the built in property: SMTPSecure as in:
$mail->SMTPSecure = "ssl";
Doing this appends the 'ssl://' to your 'smtp.gamil.com'
Though perhaps this is only in the newest versions.
Hope this helps others.
This comment has been removed by the author.
@thams007:
You can try commenting the line
$mail->AddReplyTo($webmaster_email,"Webmaster");
Well it's about time someone figured this out. Your solution worked perfectly. Thanks so much!
hello....
this is not working for me though...i just get no msg from the server when i try to send the mail as shown in the eg.
can someone please help me out???
php
//require("phpmailer/class.phpmailer.php");
include("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->Host = "ssl://smtp.gmail.com::465";
$mail->SMTPSecure = "ssl";
$mail->IsSMTP(); // send via SMTP
IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mygmailaccount@gmail.com"; // SMTP username
$mail->Password = "mygmailaccountpassword"; // SMTP password
$webmaster_email = "mygmailaccount@gmail.com"; //Reply to this email ID
$email="mygmailaccount@gmail.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?
am getting following error...
Deprecated: Function eregi() is deprecated in D:\wamp\www\ff\phpMailer\class.phpmailer.php on line 594
Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in D:\wamp\www\ff\phpMailer\class.smtp.php on line 125
Warning: fsockopen() [function.fsockopen]: Failed to enable crypto in D:\wamp\www\ff\phpMailer\class.smtp.php on line 125
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://localhost:25 (Unknown error) in D:\wamp\www\ff\phpMailer\class.smtp.php on line 125
Mailer Error: SMTP Error: Could not connect to SMTP host.
am new to php..pls help me...thanks in advances....
Thanks you working perfect!
after update, the comment-line to search is started with "//" not wtih "#"
"// connect to the smtp server"
:)
Get the latest version of phpmailer from source forge
This post is from 2006, gmail ssl support was added to phpmailer in November 2007....
Thankx for the solution, this is really a good script for sending emails through smtp.I really want to appreciate that.
WOW,This really works,
i just had to uncomment //ISSMTP()
on line 5 and remove semicolon from php.ini in front of extension=php_openssl.dll
is it possible to use the above script to send mails using mail servers like yahoo,hotmail etc without making changes in class.smtp.php????
Iam able to receive email but did not get the attachment while i uploaded in solaris server
woh...........what a blog.........Great writer.......thankx man
Thanks you wonderful script!
Hai Let me say my sincere thanks for d script..But i want full code..let me knw sir..
It works fine.. thanks a lot
If my Apache Server is 2.0.63 no SSL version, can I still use PHPMailer connect to ssl://smtp.gamil.com:465?
even i get the error that says
"SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host."
Hi,
I am working on ubuntu with a apache server. I get the following error
Warning: fsockopen() expects parameter 2 to be long, string given in /usr/share/php/libphp-phpmailer/class.smtp.php on line 107
Mailer Error: Language string failed to load: connect_host
Plz help...
Hi, I am working on ubuntu with apache running. I get the error
Warning: fsockopen() expects parameter 2 to be long, string given in /usr/share/php/libphp-phpmailer/class.smtp.php on line 107
Mailer Error: Language string failed to load: connect_host
The mail is not sent plz help...
anybody can help this problem.
"SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host."
Plz, help me..
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate. i get that erroe
Thank you very much for your help.
Adding two lines to class.smtp.php solved my problem.
the two lines:
$host = "ssl://smtp.gmail.com";
$port = 465;
I am using drupal 6.4 with SMTP module under xampp for linux.
Now I am able to send email through smtp.google.com
Thank you again.
There was an error, possibly typo, in email.php.
I don't need this line: IsSMTP(); // send via SMTP
This possibly is a duplicate of the line above.
Changing class.smtp.php by adding two lines solved my problem.
Thank you for your simple, yet insightful, suggestion.
thanks mate .. you rock .. it's a cake walk ...
sir i got serious, anybody could please send me the code to my mail...
thanks
mailto:rajsomu2001@yahoo.com
driftwood..
class.smtp.php
but where to add two lines
inside php
or
inside class
or
inside any function???
got error "Mailer Error: SMTP Error: Could not connect to SMTP host."
those files class.phpmailer.php and class.smtp.php
lines are differs based on the version...
i cant find #connect in my file..
this only from line 574
574* Initiates a connection to an SMTP server. Returns false if the
* operation failed.
* @access private
* @return bool
*/
function SmtpConnect() {
if($this->smtp == NULL) {
$this->smtp = new SMTP();
}
$this->smtp->do_debug = $this->SMTPDebug;
this my source code, please anyone check it
http://www.fileden.com/files/2009/12/9/2682101/phpgmailer.rar
using wamp server:
this the error
Could not access file: /var/tmp/file.tar.gz Could not access file: /tmp/image.jpg SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
how to
please anyone post the 2(class) or 3 php files,...
Very nice tutorial!
Gratz
when i run the script.... its neither showing the error msg nor the successful msg.... hows it possible????? probably some mistake in the code?????
Thank you very much for suggesting PHPMailer. I have been looking for similar tool and I found it here. I just downloaded it for php version 5.1 and used the example for gmail and it worked immediately without any problem. Thank you once again....
If you cannot find "#connect" in class.smtp.php due to different version, try add the $host/$port lines inside Connect() function:
----- ORIGINAL -------------
public function Connect($host, $port = 0, $tval = 30) {
// set the error val to null so there is no confusion
$this->error = null;
----------------------------
----- ADD $host & $port LINES -------------
public function Connect($host, $port = 0, $tval = 30) {
// set the error val to null so there is no confusion
$host = "ssl://smtp.gmail.com";
$port = 465;
$this->error = null;
----------------------------
Mailer Error: SMTP Error: Could not connect to SMTP host.
error happed
seems like error not in the code
can anybody tell me the whole configurations
It was working well for me. But when i updated it to my domain its showing this error
Mailer Error: SMTP Error: Could not connect to SMTP host. PHP Warning: fsockopen() [function.fsockopen]: no SSL support in this build in d:\Domains\commvehicles.com\wwwroot\travel\phpmailer\class.smtp.php on line 122 PHP Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.gmail.com:465 in d:\Domains\commvehicles.com\wwwroot\travel\phpmailer\class.smtp.php on line 122
Please can anyone help me.. iTs really urgent..
Thanks and Regs,
Mohammad Sherif A M
Deprecated: Function eregi() is deprecated in C:\wamp\www\PHPMailer_v2.0.4\class.phpmailer.php on line 592
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\wamp\www\PHPMailer_v2.0.4\class.smtp.php on line 126
Mailer Error: SMTP Error: Could not connect to SMTP host.
R.Aravindhan(GPC-POY)
i've found this error...
OK Im getting this.. Yeah I may be stupidly ovelooking something, but I checked that all three files are in my working directory..
Incidentally, this is line 2
require("phpmailer/class.phpmailer.php");
The reference to Pear is maybe the cause but I never used a mail program before..
Everything is localhost but using my gmail sntp settings as instructed..
Warning: require(phpmailer/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\alcances\phpmailer\email.php on line 2
Fatal error: require() [function.require]: Failed opening required 'phpmailer/class.phpmailer.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\alcances\phpmailer\email.php on line 2
Please hlep if your still posting to this blog..
hihi,
I am wondering how u guys able to add HTMl tags into the body ?
For instance,
hihi
For all of you who got the error:
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)
If you are using a Linux server check the following to solve the problem:
1. Check phpinfo() for --with-openssl and --with-openssl-dir
2. If you don't have it, recompile your PHP
Hope this helps!
I'm using Apache with mapbender. I edited class.smtp.php and mapbender.conf.
Incleded the following codes to class.smtp.php.
$host ="ssl://smtp.gmail.com";
$port = 465;
But i'm getting following error.
"Mailer Error:Language String failed to Load:connect_host Please try again"
Could anyone please help me !!!
i ve done following:: it is showing error::SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.Please help
getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "chetan.tukesh.dheeraj.nikhil@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->From = "chetanpaithane@gmail.com";
$mail->FromName = "Webmaster";
$mail->Subject = "This is the subject";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddReplyTo("chetan_cpaithane@yahoo.co.in","Webmaster");
//$mail->AddAttachment("/path/to/file.zip"); // attachment
//$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment
$mail->AddAddress("chetanpaithane@gmail.com","First Last");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
thank you so much ;"Sprocketonline ";
Could not access file: /var/tmp/file.tar.gz Could not access file: /tmp/image.jpg SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
Works well; No problem! (especially when applicating what is recommended on PHPMailer site:
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server)
Thanx :) nice work
Hi all,
In Localhost my code is working file. But in my remote hosting server this code not not working proper and i am getting error like"SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host. ?>". Please some one help me what should i do more for that.
Works like a top I used SendMail... Pegasus all that junk..... should have come across this much earlier...... Simple to use and implement. Thanks a bunch......
Isn't it easier just to UPLOAD ALL 3 FILES ? :) who has it working...
Thanks for the tip about ssl:// part :)
Thanks you soooo much!!! I've passed a whole journey trying to make this work without succes.
Your methode works perfectly!
hi,
i got same error
Could not access file: /var/tmp/file.tar.gz Could not access file: /tmp/image.jpg SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
after that i have done in my email.php file
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server)
as dbeauyat said
but now i am getting
Could not access file: /var/tmp/file.tar.gz Could not access file: /tmp/image.jpg
Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in C:\wamp\www\mailer\phpmailer\class.smtp.php on line 198
please anyone solve my queries.
thanks in advance
Worked for me too KUDOS _/\_
Thank you guys
Let me have a chance to say hear full of thanks you for all the help i got via this blog...
Let me tell you that,
I was new in PHP scripting...and was struggling to get the mailer script working... And then I followed Mivla comments as on November 17, 2007 5:21 PM...
And guess what...BANG!
Thanks you so much!
Ajit Mediratta
Hi all!
first of all thanks for this tutorial .
as always initially send mail didn't work for me :P , but i did a small change of
adding the following lines within the function "Connect" in class.smtp.php
as shown below (added lines to line number 115 and 116):
public function Connect($host, $port = 0, $tval = 30) {
++> $host = "ssl://smtp.gmail.com";
++> $port = 465;
// set the error val to null so there is no confusion
$this->error = null;...........
though this was obvious , i didn't do this initially and blindly followed the instruction to paste at line -104-.
hope it helps others with similar mistake !.
-manu
Thanks
it worked perfectly...
hi,
thanks for script it is running successfully on my localhost.
http://www.sitindia.co.in/php-send-mail-php-mailer-and-google/
Diwaker srivastava
Hi
I still have the same problem
Mailer Error: SMTP Error: Could not connect to SMTP host.
Ive added every thing but still nothing send
plz help me!!
Thanks you for a lot! Wonderful working this script!
Thanks again Deepakssn..
Well, it worked just fine here.
Your code was just exactly what I spend 8 hours browsing the internet.
Thanks a lot from Brazil.
Yours
Joe Berger
if i visit the link (phpmailer.sourcefore...), i get redirected to http://phpmailer.worxware.com/, and then i have to click some link at the bottom of the page... However, the download does not contain class.smtp.php
what do I do (wrong)?
@DamnYankee - Download it from here - http://sourceforge.net/projects/phpmailer/files/
I'm getting this message:
'Fatal error: Class 'PHPMailer' not found in C:\wamp\www\email.php on line 3'
My code is:
Host = "ssl://smtp.gmail.com:465";
$mail->SMTPSecure = "ssl";
$mail->IsSMTP(); // send via SMTP
What is it mean? How can I solve it?
Fatal error: Class 'PHPMailer' not found in C:\wamp\www\email.php on line 3
class.smtp.php is missing? where do i find it?
class.smtp.php is mssing?where do i find it???
i have this error
Warning: require(phpmailer/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\phpmailer\email.php on line 2
Fatal error: require() [function.require]: Failed opening required 'phpmailer/class.phpmailer.php' (include_path='.;C:\php5\pear') in C:\wamp\www\phpmailer\email.php on line 2
please help me...
i have this error
Parse error: parse error in C:\wamp\www\phpmailer\class.smtp.php on line 101
please help me...thanks guys
had this error:
"SMTP Error: Could not connect to SMTP host."
and i found that i pasted the lines:
$host = "ssl://smtp.gmail.com";
$port = 465;
outside the Connect function... pasted them now isnide and it all works just fine!
thank u very much!
please anybody here to help me out....
i am getting d error as
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
this tut works well with me
i am able to send emails using my gmail account..
more power to the author..
Hi, i work on a server that is not local >_<
I cannot change what i want as i wish it so am stuck with the php.ini how it actually is no matter what kind of problem i meet !
I pasted the author's code and changed it with my mail adresses, i changed the two lines in the class.smtp.php script exactly how it is said to do, i checked my firewall, i prayed God to help me, i gave money to the poor and fed the needy but i still get this error :
Language string failed to load: from_failedmyemail@adress.here
Somehow, within my millions of tries, i managed to make it work with hotmail but, i fear most of my partners work with gmail so i finally ask some help here (which does not ressemble me >_< i d rather find the solution on my own than to beg for it but... time flies and i have to end this website for like tomorrow :D)
Anyway, please someone help, i don t care if it s this script or another or if i have to offer my body in exchange :DDD but please show me some direction.
Thanks in advance !
My two cents
Is it possible to send mail with authentication without using mailier or PEAR package or sendmail?
I mean i want to send mail with authentication using ini_set() so for that which other settings are required for authentication?
Which are settings that can i do using ini_set()?
Thanks...:-)
Please Helpme, i try it in localhost :
and I see error like this
"Fatal error: Call to undefined function IsSMTP() in C:\AppServ\www\mail.php on line 5"
Please help me.
TQ
Really helpful. Thanks alot
Hi!
I had the same error. I just put the line "IsSMTP(); // send via SMTP" in comment, in the email.php file.
I had two other errors but the solutions are explained by other users.
Now it works. I received the email in my box.
Thank you very much!
when i tried this error displayed
Fatal error: Cannot access empty property in C:\wamp\www\email\MAIL\phpmailer\phpmailer.php on line 271
i will try it thanks..
Yes... after reading all the comments on top of reading the actual post, everything worked FLAWLESSLY. Yes...
sir i have a blog gumpul.com
i want to auto post users ads to my blog using
my gmailid
please help me
anilkumarkanneboina@gmail.com
Very Useful Code Pls take some Changes if u want to send email from server instead of gmail changes are :
$host="ur host name"
$port=25//default port no of smtp server
Username and password are ur smtpserver username and password respectively
Well, it worked just fine here.
Your code was just exactly what I spend 8 hours browsing the internet.
Thanks a lot from Turkey. tercüme
Your code didn't work because you haven't added:
$mail->SMTPSecure="tls";
$mail->Host="smtp.gmail.com";
$mail->Port=587;
For those of you who say that XpertMailer is the way to go - I spend an hour and a half trying to hack XPM so it worked with no success - just the the three above lines added to the code on this page worked brilliantly.
Many, many thanks - If I hadn't spotted this post, I'd have started from scratch and would have had to code the SMTP/SSL bit myself!
Error is occured when i send e-mail using GMAIL SMTP.
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: No such host is known. (0)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
how about using google apps accounts? Mine @gmail.com account work but not my @.com. Any advice?
Thank Mivla, it did work for me. even thought i don't have openssl.ddl in php.ini.
Thank you.......... ..... .. .
Thanks mate. Great job with explaining the necesarry settings!
Thanks a lot but i dont stand this
Fatal error: Cannot access empty property in C:\xampp\htdocs\site\phpmailer\phpmailer.inc.php on line 271
different versions confused me
what could be that?
Fatal error: Call to undefined function IsSMTP() in /home/vol7/xtreemhost.com/xth_8143861/htdocs/email.php on line 5
Please I get this error msg. somebody should help. fputs expects parameter 1 to be resource, integer in class.smtp.php
Great.... It work for me. Thanks a lot
hi..
i'm the newbie for phpmailer..
i doesn't use xamp or wamp..
i install apache and php5 differently.
so, i tried this code, but it's seems doesn't work for me..
after i run the code, it show
IsSMTP(); // set mailer to use SMTP $mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server $mail->Port = 465; // set the port to use $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "...blabla...
so, i wanna know the full step to use this code..
it's that i need to change anything at php.ini???
anyone, pleaz help me...
Hi..all
i am using wamp and this script.
I am getting error
Fatal error: Call to undefined function IsSMTP() in C:\wamp\www\New email\email.php on line 6.
I also changed in the host and port number in the smtp.inc.php as
$host ="ssl://smtp.gmail.com"; and port 465. and i also changed in php.ini i removed semicolon before extension=php_openssl.dll
but still i getting same error. please help me
tyrosaurabh@gmail.com
really works fine...........
do as per the author says........
Awesome!!!
I'm wondering how simple it is. I've been trying the whole week to find the solution,but with no luck. And here i'm now successfully sending emails to people from my PHP forms.
Thanks a lot to all the people who have contributed here!!
This script works like a charm.. no issue whatsoever..
i'm sending bulk email - of course i add a little more spice to it..
two thumbs up for the author,
You rock!
special thanks
From: Badcheaters.com
Ps. this is great for mobile advertisement!
i've created 50 gmail accounts that rotates
for every 100 email that is sent out :: worst i'm
creating more gmail accounts :: Since this works with
google, you can use it with yahoo too, smtp setting is pretty
similar -> USE YOUR BRAIN!!
I had faced all errors almost mentioned above in this forum.
I also got blank page, no error, no acknowledgment.
I also tried testing telnet command via MS-DOS.
I also tried Googling almost upto best of my efforts.
I also tried latest PHP xampp installer.
Conclusion is that (I think, but not sure) gmail, yahoo, hotmail, aol, msn etc. have secured somehow their systems from these kind of scripts, I tried all of mentioned email services with all possible combination of smtp addresses and port numbers.
At last I got solution, here it is.
SOLUTION (I did):
xampp-win32-1.6.2-installer used. (PHP 5.2.2)
winxp pro sp2 used.
PHPMailer_5.2.0 used.
Apache service running.
Mysql service running. (not required in fact)
Filezilla service running. (not required in fact)
GMX Email service (http://www.gmx.com) used (haven't tried rest of small email services).
No changes required in class.phpmailer.php .
No changes required in class.smtp.php .
I didn't use method of two lines to be added into class.smtp.php (two lines mentioned below), instead i used three lines in my file i.e (mail.php)
$host = "ssl://smtp.gmail.com";
$port = 465;
I used below these three lines method.
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmx.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
mail.php (script which sends email):
IsSMTP(); // send via SMTP
//IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmx.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "[youremail]@gmx.com"; // SMTP username
$mail->Password = "[your password]"; // SMTP password
$webmaster_email = "[youremail]@gmx.com"; //Reply to this email ID
$email="[receiver email]@gmail.com"; // Recipients email ID
$name="Usman A. Chughtai"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Usman A. Chughtai";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Usman A. Chughtai");
//......
//no changes required here upto end of script
?>
After this, This script finally sends email successfully to inbox mentioned in script.
I hope this post will help,
Have a bAlaNCeD life !
Thank You are my hero................ it is working properly......
Dileepa sisila Chandrasekera
University of Moratuwa
hi .......the mailer code is working fine.. but i`m not able to send any image file attachment,except for it any other file attachments are working fine........... so if anyone knows a solution for it,then pls help me out
Good work. Very useful u made it in simple way.Thats working very fine and while making it i feli enjoyed and interesting.U made an awesome post.
Cheers !
hello
plzzz help
i am using ubuntu server and both function, phpmailer and swiftmailer working fine by gmai and my own mailbox host as
$mail->Host = "smtp.gmail.com"
$mail->Host = "smtp.****.com" (my mailbox host)
whenever i upload and try to run the code on remote server it doesn't work. plzzzz help me
the error is-
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' in /home/vhosts/mysite.com/testing/New Folder/lib/classes/Swift/Transport/StreamBuffer.php
when is use Host = "ssl://smtp.gmail.com its not work even in my local ubuntu server error as- SMTP Error: Could not connect to SMTP host.
thans in advance
Hi,
I have tried and successfully done it. Now I am able to send HTML email via gmail.
Thanks a lot for sharing the code.
Thx bunch, this is great tutorial and great comments ^^ thx guys u r great :) i cant believe that sending an e-mail trough localhost that hard :S anyways
i've made it :)
Plz help me...
i am getting the bellow error....
Mailer Error: The following From address failed: ap******boy@gmail.com
what i have to do...
Try SMTP4PHP also! :)
https://plus.google.com/109110210502120742267/about#109110210502120742267/about
26-08-2012Mailer Error: The following From address failed: digsmoh@gmail.com
how to solve this..
My script is working fine with wamp on local machine. but it is not working on my web host.
I already enabled ssl my phpinfo displays that
http://www.mitgroupofinstitutions.com/php.php#module_openssl
but still I am getting following error
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
Language string failed to load: smtp_connect_failed Mailer Error: Language string failed to load: smtp_connect_failed
plz help me i have this warning
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\yyy\mail\mail\mail_class.php on line 103
line 103 has this code
while($str = fgets($this->smtpConnect,4096))
if you get maximum execution time error go to php.ini and change the variable
max_execution_time = 30
30 seconds is the default running time for php script.
Hi i got this error plz help me in solving it. plz plz im using xamp..
IsSMTP(); // send via SMTP IsSMTP(); // send via SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "alizain117@gmail.com"; // SMTP username $mail->Password = "********"; // SMTP password $webmaster_email = "alizain117@gmail.com"; //Reply to this email ID $email="onlineryk2@gmail.com"; // Recipients email ID $name="zAIN aLI"; // Recipient's name $mail->From = $webmaster_email; $mail->FromName = "zAINY rULEX"; $mail->AddAddress($email,$name); $mail->AddReplyTo($webmaster_email,"Webmaster"); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment $mail->IsHTML(true); // send as HTML $mail->Subject = "This is the subject"; $mail->Body = "Hi, This is the HTML BODY "; //HTML Body $mail->AltBody = "This is the body when user views in plain text format"; //Text Body if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?>
Nice blog.. Thanks for sharing this blog information with us…
Hi I already spent a day to fix this script. It works for me.
Dont forget to verify smtp port google using : telnet smtp.gmail.com 465
or 587 and use ssl or tls. I use tls and port 587. it works.
also for xampp offline user :
1. you must enable apache to
listen port 465 or 587, this setting file is in file httpd.conf.
this is the script:
SMTPDebug = 1;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure="tls";
$mail->Host="smtp.gmail.com";
$mail->Port=587;
$mail->Username = "your@gmail.com"; // SMTP username
$mail->Password = "yourpassword"; // SMTP password
$webmaster_email = "your@gmail.com"; //Reply to this email ID
$email="destinationmail@yahoo.com"; // Recipients email ID
$name="Testing"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject ";
$mail->Body = "Hi,
This is the HTML BODY testing "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
This comment has been removed by the author.
HI!
there are no line breaks in the gmail mail received!!!
new lines disapeared
I'm using oscommerce v2.2.3 for that
and last version os phpmailer.
'\n' disapeared...
I do not have fixed this issue yet!
Anyone has a clue?
thanks regards
hey thanks for sharing.. it worked for me using WAMP+GMAIL STMP.. now just wanted to figure out how do I send mail to 50 different people.. I have all emailids in my localhost database.
I enjoy reading a lot and your stories are worth reading, nice blog, keep it up.
I've been trying to send email from localhost for a couple of months. Finally I found PHPmailer.
Initially I got some errors like call to undefined function and SMTP connect() falied etc.
Then I included class.smtp.php in my work and uncommented 'extension=php_openssl.dll' in php.ini.
Now its working fine. Thanks a ton.
nice solution.....
can anyone tell me how to show images embedded into messages instead of attachment....
like if i send email to any person with some text and image inside text..when receiver open email message he found image inside the text instead of downloading attachment....
thanks in advance.....
Hello Dude,
I have Use This code but error show
IsSMTP("ssl://smtp.gmail.com::587");
$mail->SMTPAuth = true;
$mail->SMTPSecure="ssl";
$mail->Host="ssl://smtp.gmail.com";
$mail->Port=587;
$mail->Username = "systemofhrk@gmail.com"; // SMTP username
$mail->Password = "2151660323"; // SMTP password
$webmaster_email = "systemofhrk@gmail.com"; //Reply to this email ID
$email="systemofhrk@gmail.com"; // Recipients email ID
$name="Testing"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject ";
$mail->Body = "Hi,
This is the HTML BODY testing "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
I faced the same problem and I got solution from: http://www.microsoftsupportchat.com/blog/post/McAfee-Error-could-not-access-the-local-server/
Hi,
DOes anyone read this blog? If so, can someone please help answer the question in the last comment?
Thanks
Yay worked for me!!! After countless tries this one works for me...
Initially I got the error Fatal error: Class 'SMTP' not found in class.phpmailer.php. For this I replaced class.phpmailer.php with PHPMailerAutoload.php
Then the error appeared as "Parse error: syntax error, unexpected '$host' (T_VARIABLE), expecting function (T_FUNCTION) in class.smtp.php". This was because I wrong copied the line
$host = "ssl://smtp.gmail.com";
$port = 465;
outside the Connect function... I pasted them inside the connect function and works fine.
Also in email.php comment or delete the 4th line saying "IsSMTP();" Since the line is already present as "$mail->IsSMTP();"
Hope this helps... Again tons of thanks for this post
hi,
i followed instructions and showing error
Fatal error: Call to undefined function IsSMTP() in /home/www/liveonrent/htdocs/smtp/phpmailer/contact.php on line 119
cant find line 104 #connect to the smtp server in class.smtp.php??
plz help
thanks a lot fot this script
Post a Comment