SMTP-module (Drupal): verschil tussen versies

Uit De Vliegende Brigade
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:
== Externe SMTP-server gebruiken: SMTP-module + PHPMailer ==
+
Het is niet triviaal om vanuit Drupal 6 betrouwbaar email te versturen. Maar daar biedt de SMTP-module ivm. PHPMailer, de oplossing voor.
  
Dit lijkt de meest voor de handliggende oplossing te zijn. Zie verderop onder ''casussen'' voor restultaten.
+
== Installatie smtp-module ==
  
== Casus mei 2012: Storing order-notificatie-e-mails (Drupal 6) ==
+
drush -y en smtp
  
Dit betreft een storing waarbij de foutmelding gemeld werd.
+
== Installatie PHPMailer ==
  
{|
+
* Let op: Versie 2.2.1 is de laatste versie van PHPMailer die ondersteund wordt door de SMTP-module
| [[File:E-mailfoutmeldingUbercart.png|thumb|In mei 2012 kreeg ik deze foutmelding, terwijl e-mails wel degelijk verstuurd werden]]
+
* Ik plaats degelijke libraries in <code>sites/all/libraries</code>.
| [[File:E-mailfoutmelding2Ubercart.png|thumb|En dit is een bijbehorende logboekvermelding. Hier lijkt het e-mailadres van de ontvanger te ontbreken]]
 
| [[File:E-mailfoutmelding3Ubercart.png|thumb|De oplossing: Normaal staat op de regel ''E-mail admin checkout notification'' een link ''reset''. Door deze te klikken is het probleem verdwenen]]
 
|}
 
  
== Casus nov. 2012: Geen email na klonen webwinkel (Drupal 6 & Übercart) ==
+
In pseudo-code:
 
 
Zie beschrijving in een eerder hoofdstuk.
 
 
 
== Casus april 2015: Geen email na migratie (Drupal 6 & Übercart) ==
 
 
 
Dit probleem trad op na migratie van een Übercart-site naar een eigen VPS icm. een Email-Only-abonnement van TransIP. In de praktijk blijk je niet naar jezelf te kunnen emailen. Ik heb hier contact over gehad met TransIP, maar dat heeft tot op heden weinig opgeleverd.
 
 
 
== Casus lente & zomer 2015: Vaak geen email vanuit Übercart ==
 
 
 
''' Probleem & aanvullende gegevens '''
 
 
 
Bij een bepaalde Drupal 6-webwinkel ontvangen klanten vaak geen orderbevestiging:
 
 
 
* Drupal-log vermeldt geen problemen
 
* PHP-log vermeldt geen problemen
 
* In het bijbehorende ''email-only-abonnement'' staat spamfiltering op z'n laagst, nog afgezien dat spamfiltering betrekking heeft op binnenkomende email, en niet op uitgaande email
 
* Bij een test op 5 augustus kreeg ik zelf wel gewoon een orderbevestiging
 
* Er komt geen email met fouten retour.
 
 
 
''' Overgebleven mogelijke oorzaken '''
 
 
 
* Kloppen de email-gerelateerde instellingen op deze Drupal-site?
 
* Is het SPF-record correct ingevuld?
 
 
 
== Casus herfst 2015: Geen orderbevestigingen ==
 
 
 
''' Probleem '''
 
 
 
De orders van een aantal webwinkels komen niet meer aan in een Gmail-account dat gebruikt wordt voor monitoring.
 
 
 
''' Aanvullende gegevens '''
 
 
 
* Dit betreft meerdere webwinkels, terwijl er niets aan die webwinkels is veranderd
 
* Het probleem treedt op op meerdere computers
 
* De enige gemeenschappelijke factor: Gebruik Gmail
 
* Geen orders in de spambox
 
 
 
''' Mogelijke oorzaken '''
 
 
 
* Gmail past voortdurend spaminstellingen aan. Dingen die voor Gmail overduidelijk spam zijn, belanden niet in de spambox, maar worden direct verwijderd
 
* Er wordt gebruik gemaakt van generieke mailserver-instellingen. Dat geeft een mismatch met de domeinnamen waarvoor gemailed wordt. Dat wordt al snel als spam aangemerkt.
 
 
 
== Casus sep. 2015 (1): Drupal SMTP-module in gebruik nemen ==
 
 
 
Ik volg [http://www.symphonythemes.com/drupal-blog/configure-drupal-smtp-gmail deze] handleiding:
 
 
 
# Installeer Drupal-module [https://www.drupal.org/project/smtp SMTP Authentication Support]: <code>drush -y en smtp</code>
 
# Maak de smtp-module-map de werkmap
 
# Download [https://github.com/Synchro/PHPMailer PHPMailer]: <code> wget https://github.com/Synchro/PHPMailer/archive/master.zip</code>
 
# Pak PHPMailer uit: <code>unzip master.zip</code>. Nu staat het in een submap <code>PHPMailer-master</code>. Da's precies goed
 
# Verander de naam van de PHPMailer-map: <code>mv PHPMailer-master phpmailer</code>
 
# Configureer de module onder <code>Site configuration > SMTP Authentication Support</code>
 
 
 
''' Foutmelding: Class 'SMTP' not found in ... smtp/phpmailer/class.phpmailer.php on line 1291 '''
 
 
 
* Deze klasse is gedefineerd in <code>modules/smtp/phpmailer/class.smtp.php</code> maar wordt blijkbaar niet geladen
 
* Het gaf nog WSOD's ook:
 
  
 
<pre>
 
<pre>
[16-Sep-2015 17:44:10 Europe/Berlin] PHP Fatal error:  Class 'SMTP' not found in
+
cd ~/in1 # Dit is een map voor inkomende bestanden op m'n server
/home/hiero/public/daaro.nl/public/sites/all/modules/smtp/phpmailer/class.phpmailer.php on line 1291
+
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>
  
== Casus sep. 2015 (2): Drupal SMTP-module in gebruik nemen ==
+
== Configuratie ==
  
Installatie-procedure in pseudo-code:
+
* 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.
  
<pre>
+
== Gebruik ==
drush -y en smtp
 
cd ~/in2
 
wget https://github.com/Synchro/PHPMailer/archive/master.zip
 
unzip master.zip
 
cd .../sites/all/modules/smtp
 
mkdir phpmailer
 
cd phpmailer
 
cp -r ~/in2/PHPmailer/* .
 
</pre>
 
 
 
''' Configuratie '''
 
 
 
Site configuration > SMTP Authentication Support
 
  
''' Goede testmogelijkheden '''
+
* 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.
  
Het is erg handig dat je vanaf de configuratiepagina test-emails kunt sturen.
+
== WSOD ==
  
''' WSOD: Library niet gevonden '''
+
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:
 
 
Bij het ''enablen'' van de module, kreeg ik een WSOD, die onderstaande regel in het logboek achterliet.
 
 
 
== Casus Sep. 2015: Foutmelding: Class 'SMTP' not found ==
 
 
 
''' Foutmelding '''
 
  
 
  [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
 
''' Aanvullende gegevens '''
 
 
* De Drupal SMTP-module ondersteunt PHPMailer tot en met versie 2.2.1
 
* Versie PHPMailer: 5.2.13
 
* PHPMailer ondersteunt de ''Libraries API'' sinds versie 3.x
 
 
''' Mogelijke oorzaken '''
 
 
* Het mechanisme om de betreffende klasse-definitie te laden, ontbreekt
 
* Ik heb de library niet op de juiste plek gezet: De handleiding die ik volgde, was nogal out. [https://www.drupal.org/node/642138 Deze posting uit 2006 zegt:] '' sites/all/libraries/phpmailer''
 
 
''' Conclusie '''
 
 
''readme.txt'' en ''install.txt'' lezen.
 
  
 
== 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)

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

php's mail()

Externe mailserver

Drupal SMTP-module

PHPMailer

PHPMailer - SMTP-class-foutmelding

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.