Page 1 of 1

PHPmailer for sending email problem~ Help!

Posted: Sat Aug 25, 2007 2:11 pm
by nickchou
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello guys.

      I'm facing a problem 4 using PHPmailer to send email.  

error:

Message was not sent 
Mailer Error: The following From address failed: epaymanager@163.com

My code:

Code: Select all

<?php

ini_set("include_path", "C:\xampp\htdocs\bsp"); 

require("class.phpmailer.php"); 
require("class.smtp.php"); 
require("language/phpmailer.lang-en.php"); 
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.163.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "epaymanager@163.com"; // SMTP username
$mail->Password = "*****"; // SMTP password
 
$mail->From = "epaymanager@163.com";
$mail->FromName = "My Name";
$mail->AddAddress("epaymanager@163.com","Josh Adams");
//$mail->AddAddress("to2@email.com"); // optional name
 
//$mail->AddReplyTo("jyu@aemtechnology.com","AEM");
 
$mail->WordWrap = 50; // set word wrap
 
$mail->IsHTML(true); // send as HTML
$mail->Subject = "testing email";
$mail->Body = "This is the <b>HTML body</b>";
//$mail->AltBody = "This is the text-only body";
 
if(!$mail->Send())
{
    echo "Message was not sent <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
}
 
echo "Message has been sent";
?>

Can someone help me? Thanks a lot!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Aug 25, 2007 4:50 pm
by Chris Corbyn
Try using Swift Mailer and see if you get a better error.

http://www.swiftmailer.org/

It wouldn't amaze me if the PHPMailer code is disallowing the domain 163.com based on a faulty regular expression. It may be a relaying problem but I'd expect a better error message if that's the case.

remove auth

Posted: Sun Aug 26, 2007 10:04 am
by yacahuma
comment this lines
//$mail->SMTPAuth = true; // turn on SMTP authentication
//$mail->Username = "epaymanager@163.com"; // SMTP username
//$mail->Password = "*****"; // SMTP password

an change host to localhot if you are running on the same machine
$mail->Host = "localhost";


Remember to use a valid email in the from. That should work. Try it an let us know.

Posted: Sun Aug 26, 2007 9:10 pm
by nickchou
d11wtq wrote:Try using Swift Mailer and see if you get a better error.

http://www.swiftmailer.org/

It wouldn't amaze me if the PHPMailer code is disallowing the domain 163.com based on a faulty regular expression. It may be a relaying problem but I'd expect a better error message if that's the case.

The problem is I also changed other domains, but I got same error.
yacahuma wrote:comment this lines
//$mail->SMTPAuth = true; // turn on SMTP authentication
//$mail->Username = "epaymanager@163.com"; // SMTP username
//$mail->Password = "*****"; // SMTP password

an change host to localhot if you are running on the same machine
$mail->Host = "localhost";


Remember to use a valid email in the from. That should work. Try it an let us know.
I'm so sorry that it didn't work.

I guess it is because there's no SMTP server in my laptop.
And the email I filled in is valid.

the error also came out:

Warning: fputs(): supplied argument is not a valid stream resource in C:\xampp\htdocs\bsp\class.smtp.php on line 146

Warning: fgets(): supplied argument is not a valid stream resource in C:\xampp\htdocs\bsp\class.smtp.php on line 1024
Message was not sent
Mailer Error: The following From address failed: epay_manager@sina.com

It is supposed to run on the server

Posted: Sun Aug 26, 2007 11:09 pm
by yacahuma
Is not going to run on your laptop. It is suppose to run on the actual server. Can you move it to the server an try again.

Re: It is supposed to run on the server

Posted: Mon Aug 27, 2007 10:56 am
by nickchou
yacahuma wrote:Is not going to run on your laptop. It is suppose to run on the actual server. Can you move it to the server an try again.
I'm so sorry. This is my project 4 assignment.
I need to demo to my lecturer... :oops:

install an smtp server

Posted: Mon Aug 27, 2007 1:05 pm
by yacahuma
You need something in your machine to send the email. I dont know if swift mailer can send it directly.

I dont know what configuration you have but you can try to install your own little smtp server

in windows there is one called
ArGoSoft Mail Server Freeware 1.8.8.8 you can get it at downloads.com

i think you can also enable something in iis to do it. But I will try the argosoft first.

Re: install an smtp server

Posted: Mon Aug 27, 2007 10:13 pm
by nickchou
yacahuma wrote:You need something in your machine to send the email. I dont know if swift mailer can send it directly.

I dont know what configuration you have but you can try to install your own little smtp server

in windows there is one called
ArGoSoft Mail Server Freeware 1.8.8.8 you can get it at downloads.com

i think you can also enable something in iis to do it. But I will try the argosoft first.
Hi buddy~ I've installed the server with the version of 1.8.9.1
But when I tried to start the server, I got a problem:

Error starting SMTP server:[10048] Address already in use

Error starting Web server:[10048] Address already in use

Posted: Mon Aug 27, 2007 10:18 pm
by nickchou
Thanks man, I got that error because of default SMTP of windows. I closed it, and it is ok now.

Now, I have this server. So how can I use the code?

Thanks again..

Posted: Tue Aug 28, 2007 6:50 am
by Steve Mellor
Just thought it might be useful if you had a working script to check everything against.

This runs perfectly from my machine which is using Wampserver:

Code: Select all

require("phpmailer/class.phpmailer.php");
		$mail = new PHPMailer();
		$mail->IsSMTP(); // telling the class to use SMTP
		$mail->Host = "mail.mellorweb.co.uk"; // SMTP server
		$mail->Username="website@mellorweb.co.uk";
		$mail->Password="[ Of course I'm not putting the password in here  ]";
		$mail->SMTPAuth=true;
		$mail->From = "From Email";
		$mail->FromName = "From Name";
		$mail->AddAddress("steve@mellorweb.co.uk");
		$mail->Subject = "Subject";
		$mail->Body = "Hello, this is a message form your website."
All it really relies on is getting the right SMTP settings. Of course there are some SMTP hosts that don't like you using their resources on your website so that might be where you're getting the problem. But the code is sound and PHPMailer is a good system once you've got it working.