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 Robin S
      I have had this module sitting in a 95% complete state for a while now and have finally made the push to get it out there. Thanks to @teppo for his Hanna Code Helper module which I referred to and borrowed from during development.
      http://modules.processwire.com/modules/hanna-code-dialog/
      https://github.com/Toutouwai/HannaCodeDialog
      HannaCodeDialog
      A module for ProcessWire CMS/CMF. Provides a number of enhancements for working with Hanna Code tags in CKEditor. The main enhancement is that Hanna tags in a CKEditor field may be double-clicked to edit their attributes using core ProcessWire inputfields in a modal dialog.
      Requires the Hanna Code module.
      Installation
      Install the HannaCodeDialog module using any of the normal methods.
      For any CKEditor field where you want the "Insert Hanna tag" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "HannaDropdown" to the "CKEditor Toolbar" settings field.
      Module configuration
      Visit the module configuration screen to set any of the following:
      Exclude prefix: Hanna tags named with this prefix will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Exclude Hanna tags: Hanna tags selected here will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Background colour of tag widgets: you can customise the background colour used for Hanna tags in CKEditor if you like. Dialog width: in pixels Dialog height: in pixels Features
      Insert tag from toolbar dropdown menu
      Place the cursor in the CKEditor window where you want to insert your Hanna tag, then select the tag from the "Insert Hanna tag" dropdown.

      Advanced: if you want to control which tags appear in the dropdown on particular pages or templates you can hook HannaCodeDialog::getDropdownTags. See the forum support thread for examples .
      Edit tag attributes in modal dialog
      Insert a tag using the dropdown or double-click an existing tag in the CKEditor window to edit the tag attributes in a modal dialog.

      Tags are widgets
      Hanna tags that have been inserted in a CKEditor window are "widgets" - they have a background colour for easy identification, are protected from accidental editing, and can be moved within the text by drag-and-drop.

      Options for tag attributes may be defined
      You can define options for a tag attribute so that editors must choose an option rather than type text. This is useful for when only certain strings are valid for an attribute and also has the benefit of avoiding typos.
      Add a new attribute for the Hanna tag, named the same as the existing attribute you want to add options for, followed by "__options". The options themselves are defined as a string, using a pipe character as a delimiter between options. Example for an existing attribute named "vegetables":
      vegetables__options=Spinach|Pumpkin|Celery|Tomato|Brussels Sprout|Potato You can define a default for an attribute as normal. Use a pipe delimiter if defining multiple options as the default, for example:
      vegetables=Tomato|Potato Dynamic options
      Besides defining static options as above, you can use one Hanna tag to dynamically generate options for another. For instance, you could create a Hanna tag that generates options based on images that have been uploaded to the page, or the titles of children of the page.
      Your Hanna tag that generates the options should echo a string of options delimited by pipe characters (i.e. the same format as a static options string).
      You will probably want to name the Hanna tag that generates the options so that it starts with an underscore (or whatever prefix you have configured as the "exclude" prefix in the module config), to avoid it appearing as an insertable tag in the HannaCodeDialog dropdown menu.
      Example for an existing attribute named "image":
      image__options=[[_images_on_page]] And the code for the _images_on_page tag:
      <?php $image_names = array(); $image_fields = $page->fields->find('type=FieldtypeImage')->explode('name'); foreach($image_fields as $image_field) { $image_names = array_unique( array_merge($image_names, $page->$image_field->explode('name') ) ); } echo implode('|', $image_names); Advanced: define or manipulate options in a hook
      You can hook HannaCodeDialog::prepareOptions to define or manipulate options for a Hanna tag attribute. Your Hanna tag must include a someattribute__options attribute in order for the hook to fire. The prepareOptions method receives the following arguments that can be used in your hook:
      options_string Any existing string of options you have set for the attribute attribute_name The name of the attribute the options are for tag_name The name of the Hanna tag page The page being edited If you hook after HannaCodeDialog::prepareOptions then your hook should set $event->return to an array of option values, or an associative array in the form of $value => $label.
      Choice of inputfield for attribute
      You can choose the inputfield that is used for an attribute in the dialog.
      For text attributes the supported inputfields are text (this is the default inputfield for text attributes so it isn't necessary to specify it if you want it) and textarea. Note: any manual line breaks inside a textarea are removed because these will break the CKEditor tag widget.
      Inputfields that support the selection of a single option are select (this is the default inputfield for attributes with options so it isn't necessary to specify it if you want it) and radios.
      Inputfields that support the selection of multiple options are selectmultiple, asmselect and checkboxes.
      You can also specify a checkbox inputfield - this is not for attributes with defined options but will limit an attribute to an integer value of 1 or 0.
      The names of the inputfield types are case-insensitive.
      Example for an existing attribute named "vegetables":
      vegetables__type=asmselect Descriptions and notes for inputfields
      You can add a description or notes to an attribute and these will be displayed in the dialog.
      Example for an existing attribute named "vegetables":
      vegetables__description=Please select vegetables for your soup. vegetables__notes=Pumpkin and celery is a delicious combination. Notes
      When creating or editing a Hanna tag you can view a basic cheatsheet outlining the HannaCodeDialog features relating to attributes below the "Attributes" config inputfield.
      Troubleshooting
      HannaCodeDialog includes and automatically loads the third-party CKEditor plugins Line Utilities and Widget. If you have added these plugins to your CKEditor field already for some purpose and experience problems with HannaCodeDialog try deactivating those plugins from the CKEditor field settings.
    • By joshuag
      Introducing our newest [commercial] module:
      Recurme
      Processwire Recurring Dates Field & Custom Calendar Module.
      http://www.99lime.com/modules/recurme/
      One Field to Recur them ALL…
      A Recurring Dates InputField for your Processwire templates. The InputField you’ve been waiting for.
      Complex RRule date repeating in a simple and fast user interface.
      Use the super simple, & powerful API to output them into your templates.
      example:
      <? // easy to get recurring events $events = $recurme->find(); // events for this day $events = $recurme->day(); // events for this week $events = $recurme->week(); // events for this month $events = $recurme->month(); ?> <? // Loop through your events foreach($events as $event){ echo $event->title; echo $event->start_date; echo $event->rrule; echo $event->original->url; ... } ?> Unlimited Custom Calendars.
      Imagine you could create any calendar you wanted on your website. Use recurring events with the Recurme field, or use your own Processwire pages and date fields to render calendars… it’s up to you. Fully customizable. Make as many calendars as you like. Get events from anywhere. Recurme does all the hard date work for you.
      Unlimited Custom Admin Calendars too.
      Hope you like it  ,
       Joshua & Eduardo from 99Lime.
       




    • By valan
      At our site we use both email and phone authorizations at frontend. To make life easier, I've developed HelperPhone pack that handles phone numbers. This pack includes following modules for ProcessWire CMS/CMF:
      FieldtypePhoneNumber: module that stores phone numbers InputfieldPhoneNumber: module that renders inputfield for phone numbers HelperPhone: module that loads PhoneNumber and PhoneNumberConst classes, and 'libphonenumber' namespace All these modules require included PW WireData-derived class PhoneNumber and PhoneNumberConst.
      PhoneNumber class is a thin wrapper over giggsey/libphonenumber-for-php, itself is port of Google's libphonenumber. PhoneNumberConst class stores constants, used by PhoneNumber class Usage: PhoneNumber class
      $phone = '8 (916) 318-07-29 ext 1234'; // input string could be in any phone-recognizable format $phoneNumber = new PhoneNumber($phone, 'RU'); // or wire('modules')->get('HelperPhone')->makePhoneNumber($phone, 'RU'); echo ($phoneNumber->isValidNumber() ? 'Yes':'No'); // Yes echo ($phoneNumber->isValidNumberForRegion($regionCode) ? 'Yes':'No'); // Yes echo $phoneNumber->getNumberTypeTitle(); // Mobile echo $phoneNumber->getCountryCode(); // 7 echo $phoneNumber->getRegionCode(); // RU echo $phoneNumber->getNationalNumber(); // 9163180729 echo $phoneNumber->getExtension(); // 1234 echo $phoneNumber->formatForCallingFrom('US') // 011 7 916 318-07-28 echo $phoneNumber->formatForCallingFrom('GE') // 00 7 916 318-07-28
      For more methods and properties please refer to PhoneNumber and PhoneNumberConst source files. Need more? Check giggsey/libphonenumber-for-php and use it by accessing $phoneNumber->phoneNumber property - it is instance of \libphonenumber\PhoneNumber or null (if empty).
      Usage: field
      Note: on field creation, make sure that you've configured field settings
      Default region: assumed region if input phone number string is not in international format (starts with '+', etc)
      Enabled/disabled phone extentions: if disabled, phone extension will be removed on field save.
      Phone field settings in example below: default region code 'RU', phone extensions are enabled
      echo $page->phone; // +79163180729 // Note1: $page->phone stores instance of PhoneNumber and renders to string in E164 format. // Note2: E164 format does not include extension. echo $page->getFormatted('phone'); // +7 916 318-07-29 ext. 1234 echo $page->getUnformatted('phone'); // +79163180729 echo $page->phone->format(PhoneNumberConst::RFC3966); // tel:+7-916-318-07-29;ext=1234 echo $page->phone->getNationalNumber(); // 9163180729 Usage: PW selectors
      FieldtypePhoneNumber is instance of FieldtypeText. It stores phone numbers and extensions as string in E164 format with #extention (if provided by user and enabled in settings) E.g. in db it looks like this: '+79163180729#1234'. This makes it easy to query fields as any text field.
      echo $pages->find([     'template' => 'my_temlate',     'phone^=' => '+79163180729', ]); // will echo page ids where phone starts with '+79163180729' Finally
      I've decided to put it here first and later to Modules directory (based on your feedbacks).
      GitHub: https://github.com/valieand/HelperPhone
      Enjoy
    • By justb3a
      Little admin helper module: Using this module you can view all template cache settings at once. E.g. cache status, cache time (configurable). Furthermore it adds the functionality to clear the entire template cache or just the template cache for a given template. Note that this may cause a temporary delay for one or more requests while pages are re-cached.

       
      GitHub: https://github.com/justb3a/processwire-templatecacheoverview
    • By Steven Veerbeek
      Hi,
      I am trying to create a module for a webshop in which I can predefine a number of thumbnail sizes for my product images. I was thinking of storing each of these image sizes as a child page with 'width' and 'height' fields under the module page , so I can use a PageTable input field in my module to easily manage them.
      I know how to create a Pagetable field and add it to templates so I can use it in regular pages, but because I am planning on implementing some other functionalities that (I think) can't be achieved with a regular page, I need the PageTable field to work within a module.
      So far I have come up with this piece of code by trial and error:
      $page = $this->page; $field_sizes = $this->modules->get("InputfieldPageTable"); $field_sizes->title = "image_sizes"; $field_sizes->label = "Image sizes"; $field_sizes->set('parent_id', $page->id); $template = wire("templates")->get("image_size"); $field_sizes->set('template_id', $template->id); $field_sizes->set('columns', "title\nimage_width\nimage_height"); $wrapper->add($field_sizes); It works in that it does display an empty PageTable in my module. I can also add pages and they will be added as child pages under my module page, but when I do, the way the PageTable is displayed gets all messed up. Instead of showing the newly created page as a row in the PageTable, all the fields on the module page (including the PageTable field itself) are repeated within the PageTable field.
      I hope my explanation makes sense. I am fairly new to Processwire (and module development in particular) so perhaps I am just trying to use PageTable in a way it was not intended to be. Maybe you guys could give me some directions on how to achieve what I am looking for?
      Thanks!