horst

WireMailSmtp

Recommended Posts

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:

 

  • Like 2

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.

  • Like 2

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!

 

 

 

 

 

 

 

  • Like 3

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 = '')

 

  • Like 8

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.

  • Like 1

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?

  • Like 4

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

  • Like 1

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.

  • Like 1

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 ;)

  • Like 4

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.

  • 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.