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 ukyo
      Call ProcessWire API Functions Inside STRING
      Github Repo
      Current status : BETA
      Each called method must return string value !
      I added all functions, but not tested all. I focused page(), page()->render and field properties (label, description and notes). I also tested some basic pages() api calls.
      Your API calls must start with { and must end with }. For use multiple arguments inside functions, separate arguments with ~ char.
      NOTE If you pass directly arguments to api {page(title)}, this call will check for requestedApiCall()->get(arguments).
      USAGE
      processString(string, page, language); Get page title <?php $str = "You are here : {page:title}"; echo processString($str); ?> Get page children render result <?php $str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<hr>{page:render:children}"; echo processString($str); ?> Get homepage title <?php $str = "You can visit our <a hre='{pages(1):url}'>{pages:get(1):title}</a>"; echo processString($str); ?> Get title field label, description or notes <?php $str = "Our title field properties are : label: {label(title)} - description: {description(title)} - notes: {notes(title)}"; echo processString($str); ?> Multiple examples <?php $str = " <ul class='uk-list uk-list-striped'> <li><b>01: GET FIELD LABEL</b> <code>&#123;label(title)&#125;</code> <b>RESULT :</b> <code>{label(title)}</code></li> <li><b>02: GET FIELD LABEL WITH PREFIX</b> <code>&#123;label(title~=> )&#125;</code> <b>RESULT :</b> <code>{label(title~=> )}</code></li> <li><b>03: GET FIELD LABEL WITH SUFFIX</b> <code>&#123;label(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{label(title~~ <=)}</code></li> <li><b>04: GET FIELD DESCRIPTION</b> <code>&#123;description(title)&#125;</code> <b>RESULT :</b> <code>{description(title)}</code><br> <li><b>05: GET FIELD DESCRIPTION WITH PREFIX</b> <code>&#123;description(title~=> )&#125;</code> <b>RESULT :</b> <code>{description(title~=> )}</code></li> <li><b>06: GET FIELD DESCRIPTION WITH SUFFIX</b> <code>&#123;description(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{description(title~~ <=)}</code></li> <li><b>07: GET FIELD NOTES</b> <code>&#123;notes(title)&#125;</code> <b>RESULT :</b> <code>{notes(title)}</code><br> <li><b>08: GET FIELD NOTES WITH PREFIX</b> <code>&#123;notes(title~=> )&#125;</code> <b>RESULT :</b> <code>{notes(title~=> )}</code></li> <li><b>09: GET FIELD NOTES WITH SUFFIX</b> <code>&#123;notes(title~~ <=)&#125;</code> <b>RESULT :</b> <code>{notes(title~~ <=)}</code></li> <li><b>10: GET PAGE TITLE</b> <code>&#123;page(title)&#125;</code> <b>RESULT :</b> <code>{page(title)}</code></li> <li><b>11: GET PAGE TITLE</b> <code>&#123;page:title&#125;</code> <b>RESULT :</b> <code>{page:title}</code></li> <li><b>12: GET PAGE RENDER TITLE</b> <code>&#123;page:render:title&#125;</code> <b>RESULT :</b> <code>{page:render:title}</code></li> <li><b>12: GET HOMEPAGE TITLE</b> <code>&#123;pages:get(template=home):title&#125;</code> <b>RESULT :</b> <code>{pages:get(template=home):title}</code></li> <li><b>13: GET HOMEPAGE TEMPLATE ID</b> <code>&#123;pages:get(template=home):template:id&#125;</code> <b>RESULT :</b> <code>{pages:get(template=home):template:id}</code></li> </ul> "; echo processString($str); ?>
    • By Robin S
      This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now.
      Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead. This module should be considered alpha until it has gone through some more testing.
      Add Template Enhancements
      Adds some efficiency enhancements when adding or cloning templates via admin.

      Features
      Derive template label from name: if you like to give each of your templates a label then this feature can save some time. When one or more new templates are added in admin a label is derived automatically from the name. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage
      Install the Add Template Enhancements module.
      Configure the module settings according to what suits you.
       
      https://github.com/Toutouwai/AddTemplateEnhancements
    • By AAD Web Team
      Hi,
      I've put in a support request (as a followup on an existing one) for this but it's nearly 10pm Ryan's time, so I thought I'd ask on here just in case someone can help...
      Yesterday we purchased ProDrafts, but I couldn't get the key to validate. Every time I hit submit on the module settings screen the key would be removed from the field I entered it in, and then it would complain about the missing value. I put in a support request and Ryan responded last night. It turned out it was because we're behind a proxy/firewall. He gave me a fix to get around that issue - some code to go into admin.php. I put that code in and saved admin.php, but now I can't even get into our admin anymore!
      (Just to clarify, I took the code back out and saved admin.php but that made no difference. It's definitely not the new code causing the error.)
      The errors relate to a lack of permission on the ProDrafts module (see attached screenshot). We do have a key, but evidently the code Ryan gave me to add the key in via admin.php isn't taking effect before the error is thrown...?
      I tried removing the ProDrafts directory from the modules directory, but that hasn't helped.
      Is there a hook I can put in somewhere to tell it not to load ProDrafts at all, or not check the permissions? Or is there some way to manually uninstall it from the file system?
      Thanks!
      Margaret

    • By DaveP
      I just made a textformatter module that allows you to insert dummy content (lorem ipsum style) in text fields via shortcodes.
      Usage is simple - just type for example [dc3] into a textarea with this textformatter applied (plain textarea or CKEditor) and it will be replaced at runtime by 3 paragraphs of dummy content. It can also be used to populate text fields (for headings etc) using e.g. [dc4w]. This will produce 4 words (rather than paragraphs) at runtime.
      The actual content comes from an included 'dummytext.txt' file containing 50 paragraphs of 'Lorem ipsum' from lipsum.com. The 50 paragraphs is arbitrary - it could be 10 or 100 or anything in between, and the contents of that file can be changed for your own filler text if you wish.
      The slightly clever bit is that for any given page, the same content will be returned for the same tag, but the more paragraphs available in 'dummytext.txt', the less likely it is that two pages will get the same content (very roughly speaking - it's actually based on the page ID) so content selection is determinate rather than random, even though only the tags are saved to the db.
      Update
      Tags now work like this -
      [dc3] - Show 3 paragraphs ([dc:3], [dc3p] & [dc:3p] all do the same). [dc3-6] - Show 3 to 6 paragraphs randomly per page load ([dc:3-6], [dc3-6p] & [dc:3-6p] all do the same). [dc3w] - Show 3 words ([dc:3w] does the same). [dc3-6w] - Show 3 to 6 words randomly per page load ([dc:3-6w] does the same). <End update on tags.>
      If you think it might be useful, you can download it from GitHub and give it a try.
    • By Robin S
      Password Generator
      Adds a password generator to InputfieldPassword.

       
      Usage
      Install the Password Generator module.
      Now any InputfieldPassword has a password generation feature. The settings for the generator are taken automatically from the settings* of the password field.
      *Settings not supported by the generator:
      Complexify: but generated passwords should still satisfy complexify settings in the recommended range. Banned words: but the generated passwords are random strings so actual words are unlikely to occur.  
      https://github.com/Toutouwai/PasswordGenerator