4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[MOD] Simple smtp sending over ssl

(1/1)

Aleksey:
This mod allows you to send emails from the 4images gallery via smtp with SSL authentication.

-----------| Changed Files |--------------------
/includes/email.php

-----------| New files |---------------------------
/includes/SendMailSmtpClass.php

-----------| Installation |-----------------------
Step 1

Download SendMailSmtpClass.php attached on this post and copy to /includes/SendMailSmtpClass.php

Step 2
Open /includes/email.php
Find:

--- Code: ---if (!defined('ROOT_PATH')) {
  die("Security violation");
}

--- End code ---

below insert:

--- Code: --- require_once "SendMailSmtpClass.php"; // the plug-in class

--- End code ---

Find:

--- Code: ---  function send_email() {
    if ($this->use_smtp) {
      return ($this->smtp_mail($this->to, $this->subject, $this->body, $this->create_header())) ? 1 : 0;
    }
    else {
      return (mail($this->to, $this->subject, $this->body, $this->create_header())) ? 1 : 0;
    }

--- End code ---

You can delete this function or comment on the code

--- Code: ---/* ////////// Original function send_email //////////
    function send_email() {
    if ($this->use_smtp) {
      return ($this->smtp_mail($this->to, $this->subject, $this->body, $this->create_header())) ? 1 : 0;
    }
    else {
      return (mail($this->to, $this->subject, $this->body, $this->create_header())) ? 1 : 0;
    }
  } */

--- End code ---

below insert:

--- Code: ---// Mod Simple smtp ssl sending START
  function send_email() {
    global $config;
$sitename = $config['site_name'];          // the site name is taken from the gallery settings
$smtp_from = 'mygallery@gmail.com';        // sender's email and smtp login
$smtp_password = 'my_password_smtp_user';  // smtp user password
$smtp_host = 'ssl://smtp.gmail.com';       // smtp server address, do not delete the transport ssl://
$smtp_port = 465;                          // smtp port
$smtp_charset = "UTF-8";                   // encoding of email messages UTF-8 or windows-1251

$from = array( $sitename, $smtp_from);
$mailSMTP = new SendMailSmtpClass($smtp_from, $smtp_password, $smtp_host, $smtp_port, $smtp_charset);
return ($mailSMTP->send($this->to, $this->subject, $this->body, $from)) ? 1 : 0;
  }
// Mod Simple smtp ssl sending END

--- End code ---

This is an example of settings for working with mail gmail.com
Change to your own parameters.

The "word_wrap"function also doesn't work well by default.
It inserts a break in the text of your emails in unexpected places.
To disable it find:

--- Code: ---  var $word_wrap = 76;
--- End code ---

Replace:

--- Code: ---  var $word_wrap = 0;
--- End code ---

Tested on mail servers yandex.ru, mail.ru and gmail.com, smtp.beget.com

Author SendMailSmtpClass.php - Ipatov Evgeniy admin@vk-book.ru
Article https://vk-book.ru/novaya-versiya-klassa-sendmailsmtpclass-otpravka-fajlov-cherez-smtp-s-avtorizaciej-po-protokolu-ssl-na-php/
This project on github - https://github.com/Ipatov/SendMailSmtpClass

By default, emails are sent as text, but the class supports sending in html format and even sending files.

Good luck! :)

Navigation

[0] Message Index

Go to full version