horst

WireMailSmtp

Recommended Posts

Hi.

I have moved my site to another VPS and now I get "Error in hnsmtp::send : cannot connect to smtp-server!".

Differences in VPS: php 5.4 -> 5.6 and http->https. Can it be the issue in my case or I must dig in other place?

p.s. I can connect to smtp server in console with

#openssl s_client -crlf -connect smtp.yandex.ru:465

so it is not a firewall I guess.

Share this post


Link to post
Share on other sites

I had a similar situation a couple of months ago when I tried to upgrade my domains to PHP 5.6.x on my web host.  I never resolved this issue and ended up reverting to PHP 5.5.x

Note:  The following is what I found out by using Goggle search.  It may apply or not apply to your situation, however I hope that maybe it will cause others to chime in on possible solutions

All encrypted client streams now enable peer verification by default. By default, this will use OpenSSL's default CA bundle to verify the peer certificate. In most cases, no changes will need to be made to communicate with servers with valid SSL certificates, as distributors generally configure OpenSSL to use known good CA bundles. - OpenSSL changes in PHP 5.6.x (PHP Manual)

It appears that in PHP 5.6.0 (at least the version in Debian jessie, with openssl 1.0.1h-3), this function is now validating SSL certificates (in a variety of ways). First, it appears to fail for untrusted certificates (i.e. no matching CA trusted locally), and secondly, it appears to fail for mismatched hostnames in the request and certificate.

"PHP 5.6 now verifies SSL certificates, the "fsockopen" function fails in the "ConnectToHost" method due to mismatched certificate CN (expects host name, but IP is given instead)." -Klemen (PHP 5.6 compatibility)

The problem is that this change is resulting in an error on Email Class SMTP protocol:

fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

When you update to PHP 5.6+ the "CA Root" have to be set, or OpenSSL certificate verify don't work correctly.

Step One: Install CA_Root (In my case, on FreeBSD 10, via Ports)
/usr/ports/security/ca_root_nss

After install, the Pem Cert will be located at:
/usr/local/etc/ssl/cert.pem

Step Two: Add to php.ini the openssl.cafile

openssl.cafile = /usr/local/etc/ssl/cert.pem

Restart your HTTP Server, and verify with phpinfo()

References:     http://stackoverflow.com/questions/27622427/codeigniter-2x-email-class-smtp-ssl-verification-bug-on-php-5-6
                    http://www.phpclasses.org/discuss/package/14/thread/78/
                    http://php.net/manual/en/migration56.openssl.php
  • Like 1

Share this post


Link to post
Share on other sites

@cstevensjr thanks for your answer, it point me to the right direction.

The problem is in old version of smtp class: Certificate is issued to hostname, but smtp class sends IP. In the last version it was fixed and works fine for me now on php5.6.

@horst, update smtp class, please.

http://www.phpclasses.org/package/14-PHP-Sends-e-mail-messages-via-SMTP-protocol.html

  • Like 2

Share this post


Link to post
Share on other sites

@horst - just in case you missed it: https://github.com/horst-n/WireMailSmtp/issues/3

I believe I have setup my Github the wrong way, I get notify messages for allmost everything, but not for issues of my own repos. I haven't seen it, but will look into it now.

Edited by horst
  • Like 1

Share this post


Link to post
Share on other sites

There seems to be something was changed with the newer smtp class that we have changed 2 weeks ago. But anyways, it seems to be fixed now.

@Pete, please can you have a look to it? I haven't changed anything on the behave of To-Recipients, only CC and BCC.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks horst - saw your updates on Github so will have a look tonight :)

Share this post


Link to post
Share on other sites

Just tested and with the latest change you made it works perfectly - thanks!

  • Like 1

Share this post


Link to post
Share on other sites

How can I get the sender Emailaddress set in the config of the module, from a template or module?

Thank you?

Share this post


Link to post
Share on other sites

That's it.

$data = wire('modules')->getModuleConfigData('WireMailSmtp');
echo $data['sender_email'];
echo $data['sender_name'];

Thank you

Share this post


Link to post
Share on other sites

I can't believe I've not thanked you Horst for this module. I've been using it for about a year, linked to Mandrill, a match made in heaven ^_^ and no false-positive spam rejected emails.

Thank you again, cheers, -Alan.

  • Like 1

Share this post


Link to post
Share on other sites

having some trouble with CC, i'm supplying an array, like this:

$mail->cc($array);

and i know my array is good, and CC works for 1 CC (I have $mail->sendSingle(true); )

but it will only CC the last member of the array, no matter which array type i input.

......

OK - forget this, i just updated to the latest version and this was fixed...

Share this post


Link to post
Share on other sites

First time using this module and I get this error:

"it is not supported any of the authentication mechanisms required by the server"

The SMTP server is an open relay restricted by sender IP, no authentication required.

I have tested using PHPMailer succesfully.

Any ideas?

Share this post


Link to post
Share on other sites

First time using this module and I get this error:

"it is not supported any of the authentication mechanisms required by the server"

The SMTP server is an open relay restricted by sender IP, no authentication required.

I have tested using PHPMailer succesfully.

Any ideas?

Can you please provide some information regarding your setup for this website (versions of PHP/ProcessWire, type of hosting used, the hosting provider/or whether local hosted)?  Have you followed the instructions from your hosting provider regarding SMTP setup details, if not locally hosted?

Share this post


Link to post
Share on other sites

Can you please provide some information regarding your setup for this website (versions of PHP/ProcessWire, type of hosting used, the hosting provider/or whether local hosted)?  Have you followed the instructions from your hosting provider regarding SMTP setup details, if not locally hosted?

It appears this code as part of smtp.php, generates a false positive in my case (no authentication required)

While the test fails, the module still sends mail correctly.

if($success
&& strlen($mechanism)==0)
{
   $this->error="it is not supported any of the authentication mechanisms required by the server";
   $success=0;
}

Commenting out $success will make the test pass, but probably not a good idea.

Nothing special about the hosting enviroment, as I said all email scripts, the normal wireMail() works, along with PHPMailer.

The issue is the SMTP server does not require authentication, which seems to be a requirement of the smtp.php as above, which in turn causes the test of the module to fail.

Share this post


Link to post
Share on other sites

The important thing is that the emails are processed and work.  I believe if wireMail() is working then this module is working (as it uses wireMail()). 

If you could open an issue on Github, the module creator/maintainer can have a look at the issue you are reporting.

  • Like 2

Share this post


Link to post
Share on other sites

+1 what cstevensjr said re Github.

Re the problem, it sounds like the module assumes some authentication will be required (not surprised that it assumes this, surprised there's SMTP services which don't require auth).

On a general note, this module providing as it does a way to send mail via Mandrill.com, has been a life saver for me. No more lost emails due to recipients email systems assuming an email from a tiny unknown host is spam (as Mandrill delivers millions of emails their reputation is superb and so emails invariably get to their destination w/o getting rejected).

  • Like 2

Share this post


Link to post
Share on other sites

Hey, you are all right. We have had another issue with authentication and the test, where the original SMTP-class also allowed the missing of authentication. In this regard, the user could successfully pass the test (connecting to the server, IP + Port) without providing authentication credentials.

Therefore I have hacked the original class with this code you have posted above. (assuming there will be no open relay servers out there in 2015) But yep, now you comes along here. :lol:

I will have a closer look to it and provide a better fix. (apropriate for both situations). In the meantime you can A) comment the part in the code, or B) don't use the test anymore on tis server.

Thanks for your help.

  • Like 1

Share this post


Link to post
Share on other sites

This has nothing to do with WireMailSmtp but I have a question:

Can't wrap my head around this... The module is not autoloading, only extending WireMail, but it loads on demand... I'm lost :-)

Share this post


Link to post
Share on other sites

Have a look into Functions.php line 805, function wireMail():

	$mail = null; 
	$modules = wire('modules'); 

	// attempt to locate an installed module that overrides WireMail
	foreach($modules as $module) {
		$parents = class_parents("$module"); 
		if(in_array('WireMail', $parents) && $modules->isInstalled("$module")) { 
			$mail = wire('modules')->get("$module"); 
			break;
		}
	}
	// if no module found, default to WireMail
	if(is_null($mail)) $mail = new WireMail(); 

:lol:

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      An experimental module for adding images to a field via pasting one or more URLs.
      Add Image URLs
      Allows images to be added to an images field by pasting URLs.

      Usage
      Install the Add Image URLs module.
      A "Paste URLs" button will be added to all image fields. Use the button to show a textarea where image URLs may be pasted, one per line. Images are added when the page is saved.
       
      https://github.com/Toutouwai/AddImageUrls
    • By netcarver
      This module provides a very simple interface to a set of named counters. You simply call a single function, next('name'), to pull the next value out of a counter - or to set it up if it does not yet exist. Next() takes a few extra parameters to allow you to increment by values other than 1 or to start at a certain number.
      This provides some similar functionality to the built-in page naming feature of PW, and to this module recently posted by Stikki but I think it offers a little more flexibility than either. Having said that, I do like the simplicity of Stikki's new auto-increment module.
      Module Availability
      Here is my module on Github.
      Here it is in the module repository.
      Example Usage
      Here's how this module can be used to title and name a new page by adding a couple of simple hooks to site/ready.php. This example applies to new pages using a template called 'invoice' that can be quick-added to the page tree. In order to get the following to work, you must edit the template that will be the parent of the 'invoice' template and setup the template for children to "invoice" and set the "Name Format for Children" field to something other than the default blank value (I use  title  as my value.)
      <?php /** * Function to recognise our special template. */ function isInvoiceTemplate($template) { return ($template == 'invoice'); } /** * Pre-load the page title for invoice pages with a unique value * which includes a counter component. */ $pages->addHookBefore("Pages::setupNew", function($event) { $page = $event->arguments(0); $is_invoice = isInvoiceTemplate($page->template); $no_inv_num = $page->title == ''; if ($is_invoice && $no_inv_num) { $counter_name = 'WR-' . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 10, 5000); $page->title = $counter_name . '-' . sprintf("%06u", $number); } }); /** * Prevent ProcessPageEdit from forcing an edit of the name if we got here * through a quickAdd from ProcessPageAdd. We can do this because we * preset the title field in the Pages::setupNew hook. */ $pages->addHookAfter("ProcessPageEdit::loadPage", function($event) { $page = $event->return; $is_invoice = isInvoiceTemplate($page->template); $is_temp = $page->hasStatus(Page::statusTemp); if ($is_invoice && $is_temp) { $page->removeStatus(Page::statusTemp); $event->return = $page; } }); Note, the above code + module is one direct solution to the problem posted here by RyanJ.


      Version History
      1.0.0 The initial release.
    • By flydev
      PulsewayPush
      Send "push" from ProcessWire to Pulseway.
       
      Description
      PulsewayPush simply send a push to a Pulseway instance. If you are using this module, you probably installed Pulseway on your mobile device: you will receive notification on your mobile.
      To get more information about Pulseway, please visit their website.
      Note
      They have a free plan which include 10 notifications (push) each day.
       
      Usage
      Install the PulsewayPush module.
      Then call the module where you like in your module/template code :
      <?php $modules->get("PulsewayPush")->push("The title", "The notification message.", "elevated"); ?>  
      Hookable function
      ___push() ___notify() (the two function do the same thing)
       
      Download
      Github:  https://github.com/flydev-fr/PulsewayPush Modules Directory: https://modules.processwire.com/modules/pulseway-push/  
      Examples of use case
      I needed for our work a system which send notification to mobile device in case of a client request immediate support. Pulseway was choosen because it is already used to monitor our infrastructure.
      An idea, you could use the free plan to monitor your blog or website regarding the number of failed logins attempts (hooking Login/Register?), the automated tool then block the attacker's IP with firewall rules and send you a notification.
       

       
      - - -
      2017-11-22: added the module to the modules directory
       
    • By cosmicsafari
      Hi all,
      Just wondering if its possible to just add some basic output to my modules config page.
      I was wanting to output a bulleted list of some information which I will be pulling from a third party.
      Retrieving the data is fine i'm just not sure how to output it to the config page?
      From what I can see in the link below, it only seems like you can append form items to the page.
      https://processwire.com/blog/posts/new-module-configuration-options/
    • By netcarver
      A very simple textformatter that was inspired by Diogo's RemoveHeight textformatter.
      This one strips the height from any images and either adds a custom class or adds a max-width:100% as an embedded style.
      Github: https://github.com/netcarver/TextformatterFluidImages
      PW Repo: here.