horst

WireMailSmtp

179 posts in this topic

1 hour ago, Ivan Gretsky said:

Good day!
Is it somehow possible to test sending emails with WireMailSMTP without them actually being send? Something like you can do with regular php mail function in xampp where all the mail is put into a folder.

Just for the record: Adrian's Tracy Debugger module has smiliar features:

 

2 people like this

Share this post


Link to post
Share on other sites
4 hours ago, Ivan Gretsky said:

Good day!
Is it somehow possible to test sending emails with WireMailSMTP without them actually being send? Something like you can do with regular php mail function in xampp where all the mail is put into a folder.

If I understand correctly, the Mail panel in Tracy should be what you are looking for. It intercepts all wireMail() calls and shows the results in the panel instead of actually sending the emails.

578682754ac2f_ScreenShot2016-07-13at11.03.10AM.png.f4fb804b1c32109d39b1a00d58ac49c1.png

Oops - sorry about repeating the content of @szabesz's post - I replied without reading through all the replies which were on the next page.

2 people like this

Share this post


Link to post
Share on other sites

Hey guys

No problems now... Just sharing to the collective knowledge pool should someone do a search...

My site was unencrypted http and I was using Zoho Mail with no problems. Here is what I set things to and all was ok:

Outgoing Server Name: smtp.zoho.com
Port: 587 & Use START_TLS 

 

The problem came when I decided to switch the site over to a https site. And once I did that I was not getting any emails sent. Using "Test settings now" showed that I had some authorisation issues. :(

After much experimentation, the issue turned out to be that SMTP user and Sender emailaddress have to be the same value. Previously they were different email address values and worked just fine when the site was http over TLS. 

And so by making sure that SMTP user and Sender emailaddress are identical, setting the Port to 465, using SSL, and allowing self signed certificates, all is good again when sending via WireMail SMTP and Zoho Mail. At least for me! :)

Hope that saves someone 15 to 30 mins :)

Have a great week everyone, especially all the Mods!

Oh and P.S. Thanks horst for this great module!

 

 

 

 

 

 

 

3 people like this

Share this post


Link to post
Share on other sites

Updated to be in sync with the new introduced attachment function in core WireMail. (PW 3.0.36)

The attachment function was introduced in WireMailSmtp since its initial release. But it hasn't had the option to specify alternative basenames for added attachmentfiles, as it was introduced in PW core this week. :)

Now you can call in both, PW core WireMail and WireMailSMTP:

attachment($filename, $alternativeBasename = '')

 

8 people like this

Share this post


Link to post
Share on other sites

Not sure it has been mentioned before: If changing the email-name, the saved password is silently removed. Is this intended?

I would like a warning here, if there is a case where the saved password gets reset for some reason and needs to be entered again.

1 person likes this

Share this post


Link to post
Share on other sites

I'm looking for a way to dynamically change the SMTP server settings for this module depending on my environment. If I'm on my local box, I want to use Mailtrap or Debugmail.io in order to prevent test emails from going to real addresses – but on the live server I want to maintain my Mandrill credentials.

I thought it would be as simple as this:

$this->addHookAfter("TemplateFile::render", function($event) {
    $config = wire('config');
    $wmsmtp = wire('modules')->get('WireMailSmtp');
    if($config->env == "dev") {
        $wmsmtp->set('smtp_host', "different-smtp-server.com");
        $wmsmtp->set('smtp_port', "25");
        $wmsmtp->set('smtp_user', "username2");
        $wmsmtp->set('smtp_password', "a_different_password");
    }
});

But that doesn't seem to be working. I'm sure I'm using a bad hook for this, but I can't find a hook for when Module Configs are loaded - only saved - and I am almost positive that ProcessWire can do this. I just don't know how! Anybody done anything like this before?

Share this post


Link to post
Share on other sites
5 minutes ago, ethfun said:

I'm looking for a way to dynamically change the SMTP server settings for this module depending on my environment. If I'm on my local box, I want to use Mailtrap or Debugmail.io in order to prevent test emails from going to real addresses – but on the live server I want to maintain my Mandrill credentials.

I thought it would be as simple as this:


$this->addHookAfter("TemplateFile::render", function($event) {
    $config = wire('config');
    $wmsmtp = wire('modules')->get('WireMailSmtp');
    if($config->env == "dev") {
        $wmsmtp->set('smtp_host', "different-smtp-server.com");
        $wmsmtp->set('smtp_port', "25");
        $wmsmtp->set('smtp_user', "username2");
        $wmsmtp->set('smtp_password', "a_different_password");
    }
});

But that doesn't seem to be working. I'm sure I'm using a bad hook for this, but I can't find a hook for when Module Configs are loaded - only saved - and I am almost positive that ProcessWire can do this. I just don't know how! Anybody done anything like this before?

I'm a big dummy. It works if you change `$config->env == "dev"` to `$config->env = "dev"`. I had the wrong operator.

Share this post


Link to post
Share on other sites
6 minutes ago, ethfun said:

$config->env = "dev"

That will just set it to dev and proceed - it won't actually check the value of $config->env

Just an option for you - TracyDebugger has a Mail Interceptor panel which which intercepts all outgoing emails and displays their content in the panel instead - might be a decent option for what you are trying to achieve?

4 people like this

Share this post


Link to post
Share on other sites

@adrian probably! After I wrote that second message I was like, "waaaait a minute - that doesn't seem right..."

Does Tracy show the rendered HTML of the email and all the recipients, etc?

Share this post


Link to post
Share on other sites

Yes, Tracy shows the rendered HTML and all recipients. 

Back to your hook question, there is: getModuleConfigInputfields which may suit your needs, but haven't though into it too much, but it does seem to be what you were asking about.

https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/core/Modules.php#L3534

1 person likes this

Share this post


Link to post
Share on other sites

@ethfun - if you are able to figure out how to dynamically change the smtp creds let me know - that would be super useful;

for example i am doing a lot of CRM type of builds on top of PW these days, and sending email needs to be flexible to where you can change the sender and have that use a totally different account; Currently i use a modified version of WireMailMailgun which has the functionality to change those things before you send.

Share this post


Link to post
Share on other sites

Hello

Uploading files from a form and attaching these works well. What if I do want to send a string (stream) value as an email attachment, is there any way of doing that, something like

Quote

addStringAttachment()

function in PHPMailer?

Share this post


Link to post
Share on other sites
45 minutes ago, Bigizmund said:

Hello

Uploading files from a form and attaching these works well. What if I do want to send a string (stream) value as an email attachment, is there any way of doing that, something like

function in PHPMailer?

unfortunately not. But you may find a good startingpoint here: https://processwire.com/talk/topic/14072-add-image-from-input-typefile-possible-or-must-it-be-wireupload/#comment-126476

look at the

$filename = myImageExtract($data, $basename);

part, - specially the function myImageExtract with the WireTempDir class.

1 person likes this

Share this post


Link to post
Share on other sites

Hi, i have a problem with my Wire Mail SMTP Module. Apparently, the form works, but something is wrong with the email, I think, because when you send the email address, there is with a yellow mark. I'm going to show you: 

Sin título.jpg

22.jpg

And there is my code:

<script>
  app.controller('ContactoCtrl',function($scope, $http){
      $scope.page=<?php echo $page->toJSON() ?>;      
      $scope.enviarEmail = function(){
            $http.post( '/videsil/pwapi/', { do: 'getEmail', data:{
                'from': $scope.email,  
                'subject': $scope.subject, 
                'message': $scope.name + ' te ha enviado este mensaje: ' + $scope.message
            }})
             .success( function (result) {  
            console.log("email enviado", result); 

            $scope.name = null;
            $scope.email = null;
            $scope.subject = null;
            $scope.message = null;
        })
        .error(function(data){ console.log("NO enviado", data) });             
    }


});
</script>


<div ng-controller="ContactoCtrl">

<section id="contact">
        <div id="map" style="height:650px" data-latitude="39.4576737" data-longitude="-0.3628944,14" ></div>
       
    
        <div class="container-wrapper">
            <div class="container">
                <div class="row">
                    <div class="col-sm-4 col-sm-offset-8">
                        <div class="contact-form">
                            <h3 class="letravidesil">Contacto</h3>

                            <address>
                              <strong>Videsil S.L.</strong><br>
                              C/ Nino Bravo, 5, 46812 <br>
                              Ayelo de Malferit, Valencia <br>
                              <abbr title="Phone"></abbr> (+34) 96 236 0123
                            </address>

                            <form id="main-contact-form" name="contact-form" method="post" action="#">
                                <div class="form-group">
                                    <input type="text" ng-model="name" name="name" class="form-control" placeholder="Nombre y teléfono" required>
                                </div>
                                <div class="form-group">
                                    <input type="email" ng-model="email" name="email" class="form-control" placeholder="Email" required>
                                </div>
                                <div class="form-group">
                                    <input type="text" ng-model="subject" name="subject" class="form-control" placeholder="Asunto" required>
                                </div>
                                <div class="form-group">
                                    <textarea ng-model="message" class="form-control" rows="8" placeholder="Mensaje" required></textarea>
                                </div>
                                <button type="submit" class="btn btn-primary" name="submit" value="Enviar" ng-click="enviarEmail()">Enviar</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section><!--/#bottom-->
    
</div>

I don't know why is not working, because 6 months ago there was working with the same settings. Help please

Edited by kongondo
Moved your topic to the module's own support forum

Share this post


Link to post
Share on other sites

I helped @raulyjo through MP, the problem did not come from the module. It was missing a page and the template code that were probably forgotten during the migration. All good now ;)

4 people like this

Share this post


Link to post
Share on other sites

Hello all,

I am trying to setup WireMailSMTP with the Gmail SMTP server, trying everything I read in this topic with no success.

The error I get that seems to say something (but I don't know what!) is =>  WireMailSmtpConfig: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt0

The settings I am using are: (I think I entered every combination possible!)

local hostname: the site's domain (is this wrong? I don't know if it's relevant but this domain is an addon domain)

SMTP hostname: smtp.gmail.com

SMTP port: 587

use START_TLS

SMTP user: my email from Google

SMTP password: my above email password

 

Am I doing something wrong?

Share this post


Link to post
Share on other sites

Are you using 2 factor authentification? If so make sure you generate an app password instead of using the account password.

Share this post


Link to post
Share on other sites
7 minutes ago, LostKobrakai said:

Are you using 2 factor authentification? If so make sure you generate an app password instead of using the account password.

No, I am not.

Share this post


Link to post
Share on other sites

In case using Google for SMTP is the problem (perhaps Google is or may one day, restrict use?), a new account with Postmark gives you 25,000 'credits', but more importantly they are great for transactional emails.

Share this post


Link to post
Share on other sites
2 hours ago, alan said:

In case using Google for SMTP is the problem (perhaps Google is or may one day, restrict use?), a new account with Postmark gives you 25,000 'credits', but more importantly they are great for transactional emails.

Ok, I signed up for a similar service. It works now, but I have a concern: Since my site's contact form receives emails from various people (the WireMail->from() value is different every time), I am asked to validate every single one before it passes. Is this the way these services work?

 

Share this post


Link to post
Share on other sites
7 minutes ago, alexpi said:

I am asked to validate every single one before it passes. Is this the way these services work?

I choose to have the 'From' as noreply@example.com (the domain the site is on) and I ensure that domain is valid (good SPF, DKIM etc) then one validation and you're done.

1 person likes this

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 bernhard
      Hi,
      just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone.
      https://gitlab.com/baumrock/RockDummyData/
      easy example:
      $rdd = $modules->get('RockDummyData'); for($i=0; $i<15; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>"; } more advanced:
      $json = new stdClass(); $json->data = array(); $rdd = $modules->get('RockDummyData'); for($i=0; $i<3000; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); $obj = new stdClass(); $obj->name = $dummy->forename . ' ' . $dummy->surname; $obj->position = $dummy->job; $obj->office = $dummy->city; $obj->color = $dummy->color; $obj->start_date = new stdClass(); $obj->start_date->display = date('d.m.Y',$dummy->timestamp); $obj->start_date->sort = $dummy->timestamp; $obj->salary = rand(0,10000); $json->data[] = $obj; } echo json_encode($json); you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module
    • By AndySh
      Hello!
      I need your assistance please. I purchased the module FormBuilder. Unfortunately, the module discontinued delivering customer submissions to e-mail box specified in the module settings. Direct mailing to the e-mail box works OK. The module settings stays the same and are correct, like "Send e-mail to administrator(s) is checked. The last version of FormBuilder 3.0 has been installed. Please advise how to resolve the issue becase I cannot get orders from customers anymore (((
    • By kixe
      As described in this post (https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742) the option 'Name Format Children' under the tab 'Family' in template settings doesn't work properly and also not as expected. I had a look inside the code and made some changes which are working properly, which offers much more options, more consistency and less code too.

      The result is the following. You have 3 Options for generating name and title, which could be combined in endless variations.
      Name is always derived from title, same like creating pages manually.
      type date: if function detects # character anywhere in the string, conversion will be: deletion of # and string will be used as format parameter for PHP date() function type field: if string is a fieldname of the parent page the value of this field will be used type string: if string doesn't fit to the 2 preceeding it will be taken as it is All parts (separated by comma) will be composed in the order of setting. You can use unlimited numbers of parts

      I made a pull request on github: https://github.com/ryancramerdesign/ProcessWire/pull/831

      Example screenshots

      Setting ...


      will result in


       
    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
       
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend