SMTP-module (Drupal): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met '== Externe SMTP-server gebruiken: SMTP-module + PHPMailer == Dit lijkt de meest voor de handliggende oplossing te zijn. Zie verderop onder ''casussen'' voor restul...') |
|||
Regel 1: | Regel 1: | ||
− | + | Het is niet triviaal om vanuit Drupal 6 betrouwbaar email te versturen. Maar daar biedt de SMTP-module ivm. PHPMailer, de oplossing voor. | |
− | + | == Installatie smtp-module == | |
− | + | drush -y en smtp | |
− | + | == Installatie PHPMailer == | |
− | + | * Let op: Versie 2.2.1 is de laatste versie van PHPMailer die ondersteund wordt door de SMTP-module | |
− | + | * Ik plaats degelijke libraries in <code>sites/all/libraries</code>. | |
− | |||
− | |||
− | |||
− | + | In pseudo-code: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<pre> | <pre> | ||
− | + | cd ~/in1 # Dit is een map voor inkomende bestanden op m'n server | |
− | / | + | wget https://github.com/PHPMailer/PHPMailer/archive/v2.2.1.tar.gz |
+ | tar -xzf v2.2.1.tar.gz # Ik geloof dat het resultaat een map genaamd PHPMailer is, of zoiets | ||
+ | cp -r ~/in1/PHPMailer /home/hostingaccount/site/public/sites/all/libraries | ||
+ | mv PHPMailer phpmailer # Bestandsnaam moet je aanpassen naar phpmailer | ||
</pre> | </pre> | ||
− | == | + | == Configuratie == |
− | + | * De module bestaat uit maar één onderdeel dat geactiveerd moet worden (Drush zoals hierboven gedaan, of via pagina ''Modules'') | |
+ | * Er is maar één configuratie-pagina:<pre>Site configuration > SMTP Authentication Support</pre> | ||
+ | * Je hebt verder niet direct met <code>PHPMailer</code> te maken. | ||
− | + | == Gebruik == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | * Gebruik spreekt voor zich | |
+ | * Eén aspect dat super is aan deze module: Je kunt de mailfunctie testen, zowel met als zonder SMTP-module: Op de SMTP-pagina heb je onderaan het scherm de mogelijkheid om een testmail te versturen. Als je (bovenaan de pagina) de SMTP-server hebt geactiveerd, wordt die test-email via PHPMailer verstuurd. Als de SMTP-sever niet is geactiveerd, wordt er gemailed via de standaard-Drupal methode. | ||
− | + | == WSOD == | |
− | + | Als de PHPMailer-library niet correct is geïnstalleerd, geeft dan al snel een WSOD, en dit is wat het PHP-logboek er van vindt: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[17-Sep-2015 16:27:44 Europe/Berlin] PHP Fatal error: Class 'SMTP' not found in | [17-Sep-2015 16:27:44 Europe/Berlin] PHP Fatal error: Class 'SMTP' not found in | ||
/hier/daaro.nl/public/sites/all/modules/smtp/phpmailer/class.phpmailer.php on line 1302 | /hier/daaro.nl/public/sites/all/modules/smtp/phpmailer/class.phpmailer.php on line 1302 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Casus sep. 2015: SMTP-module met succes geïnstalleerd (1) == | == Casus sep. 2015: SMTP-module met succes geïnstalleerd (1) == |
Versie van 20 sep 2015 13:54
Het is niet triviaal om vanuit Drupal 6 betrouwbaar email te versturen. Maar daar biedt de SMTP-module ivm. PHPMailer, de oplossing voor.
Installatie smtp-module
drush -y en smtp
Installatie PHPMailer
- Let op: Versie 2.2.1 is de laatste versie van PHPMailer die ondersteund wordt door de SMTP-module
- Ik plaats degelijke libraries in
sites/all/libraries
.
In pseudo-code:
cd ~/in1 # Dit is een map voor inkomende bestanden op m'n server wget https://github.com/PHPMailer/PHPMailer/archive/v2.2.1.tar.gz tar -xzf v2.2.1.tar.gz # Ik geloof dat het resultaat een map genaamd PHPMailer is, of zoiets cp -r ~/in1/PHPMailer /home/hostingaccount/site/public/sites/all/libraries mv PHPMailer phpmailer # Bestandsnaam moet je aanpassen naar phpmailer
Configuratie
- De module bestaat uit maar één onderdeel dat geactiveerd moet worden (Drush zoals hierboven gedaan, of via pagina Modules)
- Er is maar één configuratie-pagina:
Site configuration > SMTP Authentication Support
- Je hebt verder niet direct met
PHPMailer
te maken.
Gebruik
- Gebruik spreekt voor zich
- Eén aspect dat super is aan deze module: Je kunt de mailfunctie testen, zowel met als zonder SMTP-module: Op de SMTP-pagina heb je onderaan het scherm de mogelijkheid om een testmail te versturen. Als je (bovenaan de pagina) de SMTP-server hebt geactiveerd, wordt die test-email via PHPMailer verstuurd. Als de SMTP-sever niet is geactiveerd, wordt er gemailed via de standaard-Drupal methode.
WSOD
Als de PHPMailer-library niet correct is geïnstalleerd, geeft dan al snel een WSOD, en dit is wat het PHP-logboek er van vindt:
[17-Sep-2015 16:27:44 Europe/Berlin] PHP Fatal error: Class 'SMTP' not found in /hier/daaro.nl/public/sites/all/modules/smtp/phpmailer/class.phpmailer.php on line 1302
Casus sep. 2015: SMTP-module met succes geïnstalleerd (1)
- phpmailer downloaden:
wget https://github.com/PHPMailer/PHPMailer/archive/v2.2.1.tar.gz
- Zie Readme- en Install-handleidingen in de appendix
- Ik kon geen patch vinden.
Met deze instellingen heb ik testmails kunnen sturen, zonder foutmelding:
- Email-Only-abonnement TransIP
- Poort 465
- SSL
Let op: Als er debugging-info wordt gestuurd, wil dat niet automatisch zeggen dat er iets mis is. In het bijzonder als je de module aanzet, komt er een enorme hoeveelheid debug-info voorbij. Bv.:
SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "220 submission2.mail.transip.nl ESMTP " SMTP -> get_lines(): $data is "220 submission2.mail.transip.nl ESMTP " SMTP -> FROM SERVER: 220 submission2.mail.transip.nl ESMTP SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "250-submission2.mail.transip.nl " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl " SMTP -> get_lines(): $str is "250-PIPELINING " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING " SMTP -> get_lines(): $str is "250-SIZE 40000000 " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 " SMTP -> get_lines(): $str is "250-AUTH PLAIN LOGIN " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN " SMTP -> get_lines(): $str is "250-AUTH=PLAIN LOGIN " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN " SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES " SMTP -> get_lines(): $str is "250-8BITMIME " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME " SMTP -> get_lines(): $data was "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME " SMTP -> get_lines(): $str is "250 DSN " SMTP -> get_lines(): $data is "250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN " SMTP -> FROM SERVER: 250-submission2.mail.transip.nl 250-PIPELINING 250-SIZE 40000000 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 " SMTP -> get_lines(): $data is "334 VXNlcm5hbWU6 " SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 " SMTP -> get_lines(): $data is "334 UGFzc3dvcmQ6 " SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "235 2.7.0 Authentication successful " SMTP -> get_lines(): $data is "235 2.7.0 Authentication successful " SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "250 2.1.0 Ok " SMTP -> get_lines(): $data is "250 2.1.0 Ok " SMTP -> FROM SERVER: 250 2.1.0 Ok SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "250 2.1.5 Ok " SMTP -> get_lines(): $data is "250 2.1.5 Ok " SMTP -> FROM SERVER: 250 2.1.5 Ok SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "354 End data with . " SMTP -> get_lines(): $data is "354 End data with . " SMTP -> FROM SERVER: 354 End data with . * phpmailer downloaden: <code>wget https://github.com/PHPMailer/PHPMailer/archive/v2.2.1.tar.gz</code> SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 3nH3Nx2Xn0z1b7X " SMTP -> get_lines(): $data is "250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 3nH3Nx2Xn0z1b7X " SMTP -> FROM SERVER: 250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 3nH3Nx2Xn0z1b7X SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "221 2.0.0 Bye " SMTP -> get_lines(): $data is "221 2.0.0 Bye " SMTP -> FROM SERVER: 221 2.0.0 Bye
Casus sep. 2015: SMTP-module met succes geïnstalleerd (2)
In pseudo-code:
drush -y smtp mkdir ..sites/all/libraries cd ../sites/all/libraries wget https://github.com/PHPMailer/PHPMailer/archive/v2.2.1.tar.gz tar -xzf v2.2.1.tar.gz mv PHPMailer-2.2.1/ phpmailer
Bronnen
- http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail_send/6 - De API die mailen verzorgd
- http://drupal.org/node/356525 - Reroute Email Module om e-mailen te testen
- http://drupal.org/node/201981 - Aardig overzicht van verschillende debug-mogelijkheden
- http://www.ubercart.org/forum/support/9146/after_completing_order_unable_send_email_please_contact_site_admin_if_problem_per
- http://www.ubercart.org/docs/user/8590/email_notifications
- http://www.ubercart.org/docs/user/305/notification_settings
php's mail()
Externe mailserver
- http://www.google.com/search?q=drupal+use+external+smtp+server
- http://www.tonyrocks.com/index.php/blogging/content-management-systems/configuring-drupal-to-use-an-external-smtp-server/
- http://stackoverflow.com/questions/6573511/how-do-i-specify-to-php-that-mail-should-be-sent-using-an-external-mail-server
- http://www.symphonythemes.com/drupal-blog/configure-drupal-smtp-gmail - Concrete implementatie
Drupal SMTP-module
PHPMailer
- https://github.com/PHPMailer/PHPMailer/releases/tag/v2.2.1 - Nieuwste ondersteunde versie
PHPMailer - SMTP-class-foutmelding
- https://www.google.nl/search?q=drupal+6+smtp+class+%27smtp%27+not+found+in+class.phpmailer.php
- https://github.com/PHPMailer/PHPMailer/issues/113
- https://www.drupal.org/node/1982536 - Fatal error: Class 'PHPMailer' not found in C
Appendix: smtp-README.txt
SMTP Authentication Support module for Drupal 6.x. This module adds SMTP functionality to Drupal. REQUIREMENTS ------------ * Access to an SMTP server * PHP version 4.0.0 and up. * The following PHP extensions need to be installed: ereg, hash, date & pcre. * The PHPMailer package from Codeworx Tech., which can be found here: http://phpmailer.worxware.com/index.php?pg=phpmailer http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/ The latest version supported is 2.2.1 * Optional: To connect to an SMTP server using SSL, you need to have the openssl package installed on your server, and your webserver and PHP installation need to have additional components installed and configured. INSTALL INSTRUCTIONS -------------------- See INSTALL.txt NOTES ----- This module sends email by connecting to an SMTP server. Therefore, you need to have access to an SMTP server for this module to work. Drupal will often use the email address entered into Administrator -> Site configuration -> E-mail address as the from address. It is important for this to be the correct address and some ISPs will block email that comes from an invalid address. Because this module uses the PHPMailer package, it is rather large and may cause PHP to run out of memory if its memory limit is small. Connecting to an SMTP server using SSL is possible only if PHP's openssl extension is working. If the SMTP module detects openssl is available it will display the options in the modules settings page. Sending mail to Gmail requires SSL or TLS.
Appendix: SMTP-INSTALL.txt
NOTE: See the REQUIREMENTS in the README.txt file. INSTALLATION INSTRUCTIONS ------------------------- 1. Copy the files included in the tarball into a directory named "smtp" in your Drupal sites/all/modules/ directory. 2. Download the PHPMailer package (the URL is listed in REQUIREMENTS section of the README.txt file). Unarchive the file and name the resulting directory phpmailer 3. You can then put the library in any of 3 places: a) sites/all/libraries (ie. sites/all/libraries/phpmailer) **recommended** b) path/to/smtp (ie. sites/all/modules/smtp/phpmailer) c) Install the libraries module and place the library at a location where library module can find it. (normally sites/all/libraries) 4. Apply the adequate patch inside the phpmailer directory (check Drupal docs on how to apply patches). 5. Login as site administrator. 6. Enable the SMTP Authentication Support module on the Administer -> Site building -> Modules page. 7. Fill in required settings on the Administer -> Site configuration -> SMTP Authentication Support page. 8. Enjoy.