Module: PHPMailer
rWatcher
Joined: 2005-09-06
Posts: 722 |
Posted: Wed, 2009-07-22 23:43 |
If anyone's interested, I've created a new module called PHPMailer which replaces Gallery's built in Sendmail code with a slightly modified version. Instead of using PHP's built in mail function, this will allow Gallery to send email messages using something called PHPMailer ( http://phpmailer.sourceforge.net/ ). For some reason my web host doesn't have PHP's mail function set up properly, so this fixes that issue for me. I've tested it against my "ContactOwner" module and done some quick testing against the notification module as well, and it appears to work fine. Should anyone run into a problem with it though, let me know. Also note that this module does not include PHPMailer. You will need to download it from the above web site and install it on your own before setting up this module. The module may be downloaded from this post, or from my github account at: I've also set up a wiki entry at: --- |
|
Posts: 7994
I've pulled this into the contrib repo. Thanks!
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!
Posts: 5
This is a great module, although having an issue with using it with a gmail/googleapps account. I know in gallery 2, to make it work I had to use tls://smtp.gmail.com|465 as the smtp server. I believe from what I can see in your code, it looks like you are passing the variables in. I have seen posts on google about using phpmailer with gmail, but can't seem to get it to work with this module. If you could provide any guidance that would be great. (by the way i'm running libphp-phpmailer on ubuntu)
Thanks
Posts: 722
I've just updated this module for use with the new Gallery 3.0 release. It can be found on my github and attached to this post.
Posts: 573
send a pull request to bharat so he can sync up the main gallery3-contrib repo with it..
--
For Gallery 3 modules and themes, visit GalleryModules.com.
For PHPNuke, phpBB2, and phpBB3 integration help, visit NukedGallery.net.
Posts: 7994
Pulled!
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 68
I'm abit confussed what this module does & how to set it up!
Is it to upload via email to your gallery or send out email of your uploaded photo!
Posts: 27300
Neither, from the docs:
"PHPMailer is a module for Gallery 3 which will allow Gallery to use PHPMailer instead of php's built in mail function."
Posts: 7
How I can Setup PHPMailer with GMail?
and
What Is "Location of PHPMailer Class"
Posts: 1
Hi,
I've installed phpmailer 5 in htdocs/phpmailer, but, I don't know what is "Location of PHPMailer Class", Do I have to insert "/phpmailer/class.phpmailer.php"? it doesn't work. Do you help me please?
Thanks for all.
Posts: 81
I am using PHPMailer and I am also using ContactOwner modules. When I try to send an email to the owner I get the follwoing error message:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. When I reload I get this:
-(
Dang... Something went wrong!
We tried really hard, but it's broken.
Hey wait, you're an admin! We can tell you stuff.
There's an error message below and you can find more details in gallery3/var/logs (look for the file with the most recent date on it). Stuck? Stop by the Gallery 3 Forums and ask for help. You can also look at our list of open tickets to see if the problem you're seeing has been reported. If you post a request, here's some useful information to include:
Platform information
Host name: my.site
Operating system: Linux 2.6.34.7-0.7-desktop
Apache: Apache/2.2.15 (Linux/SUSE)
PHP: 5.3.3
MySQL: 5.1.46-log
Server load: 0.00 0.00 0.00
Graphics toolkit: imagemagick
Gallery stats
Version: 3.0 (Santa Fe)
Albums: 194
Photos: 12735
Kohana_Exception [ kohana/core.errors.403 ]:
@todo FORBIDDEN
MODPATH/gallery/helpers/access.php[ 194 ]
189
190 /**
191 * Terminate immediately with an HTTP 403 Forbidden response.
192 */
193 static function forbidden() {
194 throw new Kohana_Exception("@todo FORBIDDEN", null, 403);
195 }
196
197 /**
198 * Internal method to set a permission
199 *
MODPATH/gallery/helpers/access.php[ 417 ] » access_Core::forbidden()
MODPATH/gallery/libraries/MY_Forge.php[ 42 ] » access_Core::verify_csrf()
MODPATH/forge/libraries/Forge.php[ 164 ] » Forge->validate()
MODPATH/gallery/libraries/MY_Forge.php[ 41 ] » Forge_Core->validate()
MODPATH/contactowner/controllers/contactowner.php[ 112 ] » Forge->validate()
{PHP internal call} » ContactOwner_Controller->sendemail( arguments )
SYSPATH/core/Kohana.php[ 331 ] » ReflectionMethod->invokeArgs( arguments )
{PHP internal call} » Kohana_Core::instance( arguments )
SYSPATH/core/Event.php[ 208 ] » call_user_func_array( arguments )
APPPATH/Bootstrap.php[ 67 ] » Event_Core::run( arguments )
DOCROOT/index.php[ 97 ] » require( arguments )
Any help would be appreciated!
Posts: 81
I played some more with this, but I still get this error. There is something to do with permissions obviously, but I can't figure out what exactly. Any help would be appreciated.
Posts: 81
Any help?
Posts: 81
Did anybody made this work at all?
Posts: 722
Here is the lastest version of the PHPMailer module. I have included the fix from ticket 1572 and added support for ssl as requested in ticket 1573.
Posts: 81
OK. I put it in, provided all the necessary SMTP information, provided the phpmailer path and nothing. Who is using this module and how is it used? Is it working in conjuction with the "contact owner" module or is the contact owner module using it?
Posts: 722
What happens? Do you get an error message, or does the email just not get sent, or something else? Does anything show up in /var/logs?
This module allows you to replace Gallery's built in method for sending email messages with PHPMailer. It should work in conjunction with anything that needs to send out an email and has been tested with the Contact Owner, eCard, and Notification modules in conjunction with Gallery 3.0.1.
Explanation of settings --
Location of PHPMailer Class: The server path to the class.phpmailer.php file (which must be installed separately). If you're on a linux server, this should look something like "/path/to/class.phpmailer.php" and if you're on a windows server this should look something like "c:\path\to\class.phpmailer.php".
From Email Address: The email address that messages will be sent from. Some SMTP server's restrict you to only sending mail from a specific address, others will let you send email from any address. Make sure the address that you specify here is valid for use with your server.
From Name: This can be anything. It'll show up on the from line in all email messages that Gallery sends.
SMTP Server Address: A valid smtp server address, ex: smtp.example.com
SMTP Login Name / SMTP Password: The login name and password for the SMTP server, if required.
SMTP Port: The port number, default is 25 for unencrypted servers, and usually either 587 or 465 for encrypted servers, although some smtp servers may use a completely different port number.
Use SSL?: Check this box if you're SMTP server requires encryption (ex: gmail).
Posts: 81
rWatcher, thanks a lot!
Based on your descritpion I got it configured correct.
The effect is basically nothing gets sent. I checked the /var/log and the only thing I see is in the apache2/access.log:
mylaptop - - [26/May/2011:14:33:30 -0400] "POST /gallery3/index.php/contactowner/sendemail/2 HTTP/1.1" 500 - "http://mygallery/gallery3/index.php/contactowner/emailid/2" "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"
Firefox gives me an empty screen and in the chrome I get:
Server error
The website encountered an error while retrieving http://mygallery/gallery3/index.php/contactowner/sendemail/2. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this web page later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Any help would be appreciated!
Posts: 722
That doesn't really tell me much Is there anything in the gallery3/var/logs folder?
Also, do you know what version of PHPMailer you have installed? I did all my testing against 5.1:
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/
There are two files you should have on you're server that come with phpmailer -- class.phpmailer.php and class.smtp.php (there's also a third file that it comes with called class.pop.php, but I think it should work fine if that's missing).
PHP Mailer comes with some test scripts, are you able to use any of them to send test messages (specifically test_smtp_basic.php -- you'll have to manually edit it to specify a mail server and login/password/etc)? That would tell us if php mailer it'self is working properly or not.
Posts: 2
Having a similar issue, no emails being sent for password reset or new user registrations. The web page stops processing (no error is given) and does not progress. The PHP mailer test page generates an email with out error.
official Gallery 3.0.2
PHP Version 5.2.15 php info page http://troy.neven.info/test1.php
PHPMAILER version Version 5.1 (October 20, 2009)
Apache version 2.2.17
cPanel Pro 1.0 (RC1)
Log file message:
2011-05-30 04:27:36 -05:00 --- error: Exception [ 0 ]: @todo SEND_MAIL_FAILED
/home/nevenin1/public_html/troy/modules/phpmailer/libraries/Sendmail.php [ 90 ]
#0 /home/nevenin1/public_html/troy/modules/register/helpers/register.php(103): Sendmail_Core->send()
#1 /home/nevenin1/public_html/troy/modules/register/helpers/register.php(50): register_Core::_sendemail('deleted@neven.info', Object(SafeString), Object(View))
#2 /home/nevenin1/public_html/troy/modules/register/helpers/register.php(91): register_Core::send_user_created_confirmation(Object(Pending_user_Model), '700c4c05c676803...')
#3 /home/nevenin1/public_html/troy/modules/register/controllers/register.php(42): register_Core::create_new_user(5)
#4 [internal function]: register_Controller->handler()
#5 /home/nevenin1/public_html/troy/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(register_Controller), Array)
#6 [internal function]: Kohana_Core::instance(NULL)
#7 /home/nevenin1/public_html/troy/system/core/Event.php(208): call_user_func_array(Array, Array)
#8 /home/nevenin1/public_html/troy/application/Bootstrap.php(67): Event_Core::run('system.execute')
#9 /home/nevenin1/public_html/troy/index.php(102): require('/home/nevenin1/...')
#10 {main}
line 85 of /modules/phpmailer/libraries/Sendmail.php suggests that has some thing to do with the new line separators of the email headers, referring to the this comment in the code:
// The docs say headers should be separated by \r\n, but occasionaly that doesn't work and you
// need to use a single \n. This can be set in config/sendmail.php
Not able to locate config/sendmail.php so I am not sure what to do next.
Any ideas?
Posts: 81
This is from the smtp_basic. Works great. I receive an email. Settings in the gallery settings and the test file are the same.
SMTP -> FROM SERVER:220 mx.google.com ESMTP m16sm148529qck.40
SMTP -> FROM SERVER: 250-mx.google.com at your service, [71.178.50.63] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK m16sm148529qck.40
SMTP -> FROM SERVER:250 2.1.5 OK m16sm148529qck.40
SMTP -> FROM SERVER:354 Go ahead m16sm148529qck.40
SMTP -> FROM SERVER:250 2.0.0 OK 1306862040 m16sm148529qck.40
Message sent!
Posts: 81
Forgot to add. I use the PHPMailer version that you specified above.
I still get the error:
The website encountered an error while retrieving http://mygallery/gallery3/index.php/contactowner/sendemail/-1. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this web page later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
I am trying Contact the Owner link.
Posts: 722
Here is the latest version of the PHPMailer module. It has been tested against Gallery 3.0.2 and PHPMailer 5.1 and works fine for me.
I've added lots of additional error handling and error logging code to this version. Hopefully if it's still not working there will at least be something useful in the gallery3/var/logs folder to explain what's going wrong instead of just the generic "@todo SEND_MAIL_FAILED".
Posts: 1
Thanks rwatcher. This works great now. The one thing I did encounter that may be tripping some people up is the path to the "class.phpmailer.php. I was getting the blank white screen until I added the "class.phpmailer.php to the end of the path which in my case on ubuntu 10.04 LTS server was the following /usr/share/php/libphp-phpmailer/class.phpmailer.php . Using this it worked perfectly. I did use the libphp-phpmailer version 5.1-5 install from ubuntu repository instead of just downloading it from sourceforge.
Posts: 81
I think adding class.phpmailer.php at the end was the key. I replaced the module with the new one rWatcher provided, but still got the white empty screen. Once I added "class.phpmailer.php" at the end of the path, everything works as a charm now!
rWatcher I think you should make a note on that.
Posts: 722
I'm glad it's working now
I've updated the codex to mention that class.phpmailer.php must be specified as part of the path.
Posts: 2
My issues were around incorrect SMTP options, the additional logging exposed my stupidity.
Thanks
Posts: 722
Glad it's working for everyone now
Posts: 3
I have installed this on my site, and have it working with the test functions, and now contact owner.
However it does not seem to work for the basket module? I cannot determine if this is the basket module or phpmailer causing the issue, as I have never been able to get the mail working from basket.
No errors showing in the log files, and site operates as normal, except without mail being sent.
Any ideas?
Posts: 722
Checking...
basket doesn't use gallery's sendmail library, it accesses the php mail function directly. See /modules/basket/helpers, lines 372 and 387:
https://github.com/rWatcher/gallery3-contrib/blob/master/3.0/modules/basket/helpers/basket.php
The author would have to update this module to use Gallery's sendmail function instead of accessing mail directly, similar to what the contact owner modules does around lines 149-155 in modules/contactowner/controllers/contactowner.php:
https://github.com/rWatcher/gallery3-contrib/blob/master/3.0/modules/contactowner/controllers/contactowner.php
Posts: 3
What is the chance of you modifying the module for me so I can get my site up and running - while I request the module be changed?
This is the only thing stopping my site from getting up and running
Posts: 2
Für alle Benutzer in Deutschland die "HostEurope" als Provider verwenden,
habe ich das Modul von rWatcher angepasst, damit es auch dort funktioniert.
For all Users of HostEurope,
we have edited the file sendmail.php of the modul from rWatcher at line 89-91
Original (sendmail.php)
Änderungen/ Changes
Posts: 722
Unless I'm missing something, this change will prevent my PHPMailer module from using PHPMailer. If you want to use PHP's mail function, why not just stick with the default Sendmail.php file at /modules/gallery/libraries/Sendmail.php?
Posts: 2
The original sendmail.php file don't support SSL
Posts: 36
Anyone getting phpmailer causing them to not be able to create albums? WHen i disable it I go to add an ablum and click create and the page loads. When i enabled PHPmailer and i perform the same actions the page never reloads. The album is created but the page never reloads.
Posts: 722
Works fine for me with Gallery 3.0.2. What modules do you have installed that use PHPMailer? Maybe it's some kind of issue between PHPMailer and a module I don't have installed.
Posts: 12
Hi
This might be an obvious question, so apologies in advance.
I am using this plugin as my webhost changed settings prevent php mail from working. However, I have found several modules that need email, don't seem to work. The ones I have found so far are Favorites and Shopping basket.
I know this module is set up and running OK as I can use contact form which uses this module all ok.
Should this module override all other settings and modules that require email just switch to using this module, or is it that these modules are coded just to use php mail functions?
Like I said, probably obvious question but some guidance would be appreciated.
Many thanks
Mark
Posts: 722
This module replaces Gallery's sendmail library with one that's been modified to use phpmailer instead of mail. Any module that relies on Gallery's sendmail library will automatically switch over to phpmailer while this module is enabled.
Posts: 81
Recently upgraded to 3.0.4 and started getting an error msg when I try to use sendmail:
Platform information
Host name: gal.site
Operating system: Linux 3.1.9-1.4
Apache: Apache/2.2.21 (Linux/SUSE)
PHP: 5.3.10
MySQL: 5.5.16-log
Server load: 0.03 0.04 0.05
Graphics toolkit: imagemagick
Gallery stats
Version: 3.0.4 (Ricochet)
Exception [ 0 ]: @todo SEND_MAIL_FAILED
MODPATH/phpmailer/libraries/Sendmail.php[ 90 ]
85 // The docs say headers should be separated by \r\n, but occasionaly that doesn't work and you
86 // need to use a single \n. This can be set in config/sendmail.php
87 $headers = implode($this->header_separator, $headers);
88 $message = wordwrap($this->message, $this->line_length, "\n");
89 if (!$this->mail($to, $this->subject, $message, $headers)) {
90 throw new Exception("@todo SEND_MAIL_FAILED");
91 }
92 return $this;
93 }
94
95 public function mail($to, $subject, $message, $headers) {
MODPATH/contactowner/controllers/contactowner.php[ 155 ] » Sendmail_Core->send()
{PHP internal call} » ContactOwner_Controller->sendemail( arguments )
SYSPATH/core/Kohana.php[ 331 ] » ReflectionMethod->invokeArgs( arguments )
{PHP internal call} » Kohana_Core::instance( arguments )
SYSPATH/core/Event.php[ 208 ] » call_user_func_array( arguments )
APPPATH/Bootstrap.php[ 67 ] » Event_Core::run( arguments )
DOCROOT/index.php[ 113 ] » require( arguments )
I have my PHPMailer:
gal:/usr/lib/php5/classes/PHPMailer_v5.1 # ls
LICENSE aboutus.html class.phpmailer.php class.smtp.php examples test
README changelog.txt class.pop3.php docs language
WHat seems to be wrong?
Thanks!
Posts: 1
personally I've had headaches with this issue of the mails ... finally thank you for your answers, do not consider myself a geek hehe ;)
Greetings guys