View Full Version : phpmailer
westdor
2nd March 2006, 20:46
Hi all,
Afraid like princ i have a question regarding mail.
I want to use phpmailer so I can use smtp and also use multiple smtp servers(incase one fails)
I believe I don't have access to the 'php.ini include_path' so the alternative is to do this:
QUOTE
Copy class.phpmailer.php into your php.ini include_path. If you are using the SMTP mailer then place class.smtp.php in your path as well. If you do not have control of the include directory and you are running PHP 4.0 or higher you can use this function to set it to the correct directory:
ini_set("include_path", ".:/path/to/phpmailer/dir");
Or this:
$mail->PluginDir = "/path/to/phpmailer/dir";
Could someone explain this to me please as i'm sure it makes perfect sense but to me it may as well be Cantonese.
Many thanks
westdor
2nd March 2006, 20:49
I understand i can use a directory to put the files above in but where do I include that in this page?
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@site.com","Josh Adams");
$mail->AddAddress("ellen@site.com"); // optional name
$mail->AddReplyTo("info@site.com","Information");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$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";
Would it be on the top line? ie:
require("path/to/dir/class.phpmailer.php");
and is that it?
thx
Steve
2nd March 2006, 21:18
Hello,
Is it possible to select an option in this script to use the PHP mail(); command? This is the easiest way of sending out emails via PHP and should work everytime. :)
Regards,
westdor
2nd March 2006, 21:37
Hi Steve, yes i use the mail() command but it doesn't always work. mainly because if there is a server problem even for a second, it fails to send and will not retry.
With sending via smtp it will keep trying and also you can add more than one smtp server.
I am hoping i have sorted my problem above by simply putting the phpmailer files into a seperate directory. I am getting errors but hopefully I can sort them.
Will let you know so you can close this thread.
Thx for the reply
Steve
2nd March 2006, 21:41
No problem, let me know how it goes. :cool:
westdor
2nd March 2006, 22:22
I managed to get it working ok.
The descructions are not very good imho as they only really cover installing on a 'box' rather than uploading to a host.
I am only using the smtp function at present but works ok without the need for the mailer files to be in the php.ini include path. Will test the other class functions later.
Thanks
ps. I use email verification in my login script so needed a mailer that was less prone to problems, will see if this has any probs
Steve
3rd March 2006, 09:19
Good to hear that you managed to get it working. :)
westdor
4th March 2006, 17:08
Hi Steve,
afraid i was a bit premature. It only works on email addresses assigned to my domain here. it won't send to an email address to someone else.
I have gone back to the simple php mail() function but have the same problem. It will not send an email to anyone other than my email accounts on my domain here.
I tested the script on another domain and it sends emails no problem, even to isp such as AOL and BT Yahoo, but will not send one to my email addresses to my domain here.
Is this a firewall issue? Wonder if this is related to princ thread???
Just to recap:
Mail function script will not send emails to any address apart from mine residing on this server. If I move the same script to another domain, it sends fine apart from emails to my address on this domain.
Any thoughts?
Regards
Jon
Steve
4th March 2006, 19:37
Hi Jon,
That's strange - PHP mail() should send emails without problems to any email addresses. Can you try creating a small PHP test file that uses the mail() command to see if this can send out email? This will rule out a server side problem. :)
Regards,
westdor
5th March 2006, 02:27
thx steve, will tomorrow
westdor
5th March 2006, 18:04
<?php
$email = "various";
$mysite = "my website";
$myemail = "info@westdorset.org.uk";
$subject = "Test";
$message = "This is a test.";
mail($email, $subject, $message, "From: $mysite <$myemail>\nX-Mailer:PHP/" . phpversion());
?>
I have tried 5 different emails in $email and the only one to get through is one to westdorset.org.uk
Am i missing something?
Steve
5th March 2006, 18:21
Hi Jon,
I havn't tested your PHP mail() code but everything seems fine. I just wrote the following:
<?php
$to = "user@domain.com";
$subject = "Test Email";
$body = "This is a test email sent by PHP.";
$headers = "From: steve@statichost.co.uk\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
?>
I tested it on our Proton server and it sends emails to remote addresses without problems. (Hotmail, etc.)
Can you PM me with one of your remote email addresses? I will try sending a test email to it using this script. :)
Tom
18th April 2006, 15:04
Just a simple test script...
<?php
// Change to the destination email...
$ToEmail = "example@statichost.co.uk";
// Change the email you want to display in the "From:" line
$FromEmail = "example2@statichost.co.uk";
if(mail($YourEmail,"Test Email","This email confirms that sendmail is working correctly on the server!\nThanks for testing!","From: ". $FromEmail)) {
echo("Mail Sent, please check your email.");
} else {
echo("Mail failed.");
}
?>
Ooops, I just noticed a similar one above... oh well, c'est la vie.
Steve
18th April 2006, 15:55
Just a simple test script...
Thanks for that Tom, it looks more comprehensive than mine. :D
westdor
24th April 2006, 23:23
Hi Steve, sorry it took so long to reply.
Either way, either script I am still having problems. If you sent me emails re: my pm to you, I didn't receive them.
I Have double checked everything I can think of and written many testing scripts but all have the smae problem which isn't anything to do with your server as i have tested the scripts on another server as well with the same results.
Here is my problem, maybe someone can shed some light on it.
It appears that if I send mail to an isp email address, that is for example: addy@btinternet.com, addy at pipex.com, addy at tiscali.com, etc; they send without any problem.
If I send mail to any pipex hosting email address. (webfusion) or supanames hosting, I get an error, UNROUTABLE ADDRESS.
I do not know if this is a problem with ALL hosting mail boxes as I have no others to try.
Any thoughts?
Steve
25th April 2006, 08:25
Hello Jon,
If emails can be sent to pipex.com, tiscali.com, etc. then this suggests that email is working fine on our end. It seems like it is only emails to webfusion or supanames hosting that is having problems. Have you tried contacting webfusion or supanames to see if it is anything on their end? :)
Regards,
westdor
25th April 2006, 11:52
Hi Steve, I have had a reply from Supanames and they say there is nothing wrong at their end, no reply from pipex although none expected.
It isn't anything to do with your end, but wonder if this is 'normal' for web based email???
My problem is that I don't know how email mail boxes work!
What it the difference between an email address given via an isp, and ones you create with a hosting account, if any???
The only mention I can find on the net is DNS filtering or spam blocking software.
westdor
25th April 2006, 12:32
I was wondering whether the "nobody@" is the cause of the problem?
I have 'sender', and 'from' variables in the script but when the email gets returned like below. the recieved is from 'nobody'.
Again i don't know enough about mail but wonder if this info is being sent then spam blocking could be the cause??
Any thoughts on how to change it??
Return-path: <>
Envelope-to: info@westdorset.org.uk
Delivery-date: Tue, 25 Apr 2006 12:26:48 +0100
Received: from mailnull by proton.statichost.co.uk with local (Exim 4.52)
id 1FYLgu-0005P6-Id
for info@westdorset.org.uk; Tue, 25 Apr 2006 12:26:48 +0100
X-Failed-Recipients: info@ttsmedia.com
Auto-Submitted: auto-generated
From: Mail Delivery System <Mailer-Daemon@proton.statichost.co.uk>
To: info@westdorset.org.uk
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1FYLgu-0005P6-Id@proton.statichost.co.uk>
Date: Tue, 25 Apr 2006 12:26:48 +0100
X-Antivirus: AVG for E-mail 7.1.385 [268.4.4/320]
Mime-Version: 1.0
Content-Type: text/plain
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
info@ttsmedia.com
Unrouteable address
------ This is a copy of the message, including all the headers. ------
Return-path: <info@westdorset.org.uk>
Received: from nobody by proton.statichost.co.uk with local (Exim 4.52)
id 1FYLgu-00024v-F5
for info@ttsmedia.com; Tue, 25 Apr 2006 12:26:48 +0100
To: info@ttsmedia.com
Subject: WDCW Registration
Date: Tue, 25 Apr 2006 12:26:48 +0100
From: Jon <info@westdorset.org.uk>
Message-ID: <1e25a2d04b1395085e3946dcb22c1b5e@www.westdorset.or g.uk>
X-Priority: 3
X-Mailer: PHPMailer [version 1.73]
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_1e25a2d04b1395085e3946dcb22c1b5e"
Many thanks
Steve
25th April 2006, 15:57
Hello Jon,
My problem is that I don't know how email mail boxes work!
What it the difference between an email address given via an isp, and ones you create with a hosting account, if any???
There isn't really any difference. They both run mail server software, but how you communicate with it is different. The end result is the same. :)
The only mention I can find on the net is DNS filtering or spam blocking software.
It is possible that spam blocking software is installed on their servers. All emails using PHP are sent via nobody@, this is normal behaviour as Apache runs as "nobody" on linux.
westdor
25th April 2006, 17:24
thx Steve.
At least with phpmailer the ones that don't get sent get returned to me which is important.
thx again
westdor
29th December 2006, 20:05
Steve,
After sorting all my problems out with phpmailer. I have found that i am yet again experiencing problems sending.
I have a few scripts that use phpmailer and been using it successfully for quite some time now. In the last couple of days my mail is no longer sent and there hasn't been any alterations to my site. I have checked and checked and find no problems at my end. Is there any reason for this you can think of?
After receiving probably 60 or so emails from my site, I now receive none, I don't even get a mail delivery email.
Any thoughts?
Steve
29th December 2006, 21:53
Hello,
Have you recently enabled any spam filters or anything of that nature? It seems strange that you would just suddently stop receiving emails from your site.
Regards,
westdor
29th December 2006, 21:56
Hi, it appears that superglobals maybe "OFF"?? when they used to be on??
I am having a little success by checking all the scipts and unstead of using globals I am using 'include' instead.....
Steve
29th December 2006, 22:01
Hello,
Register_globals are on so the PHP Superglobals (Predefined variables) should be working - can you upload a phpinfo(); page to your website and PM me the link to it, so that I can check this? :)
Regards,
westdor
29th December 2006, 22:23
sry yes register_globals.
http://www.westdorset.org.uk/info.php
westdor
29th December 2006, 22:25
reg globals...on
strange that it won't read the global vars?? it did but not now
Steve
30th December 2006, 12:31
reg globals...on
strange that it won't read the global vars?? it did but not now
Have you tried creating a simple PHP page and just tried echo'ing one of the global variables?
westdor
1st January 2007, 15:48
Yes I did Steve and not reading any $site>
I used the include function on my mailer pages instead, so no longer need the global vars.
A work-around but works fine this way.
Thanks anyway Steve.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.