Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to allow insecure SSL #60

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function handle_mail_message_send(Doku_Event &$event, $param) {
$smtp->setServer(
$this->getConf('smtp_host'),
$this->getConf('smtp_port'),
$this->getConf('smtp_ssl')
$this->getConf('smtp_ssl'),
$this->getConf('smtp_ssl_allow_insecure')
);
if($this->getConf('auth_user')){
$smtp->setAuth(
Expand Down
15 changes: 9 additions & 6 deletions classes/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getFromEmail() {
}

/**
* Get a list of all recipients (mail only part)
* Get a list of all recipients (array of email => name, name is omitted)
*
* @return array
*/
Expand All @@ -51,16 +51,19 @@ public function getTo() {
// We need the mail only part of all recipients
$addresses = explode(',', $this->rcpt);
foreach($addresses as $addr) {
// parse address
// Parse address
$parsedAddr = '';
if(preg_match('#(.*?)<(.*?)>#', $addr, $matches)) {
$rcpt[] = trim($matches[2]);
$parsedAddr = trim($matches[2]);
} else {
$rcpt[] = trim($addr);
$parsedAddr = trim($addr);
}
// Insert only non-empty address
if (!empty($parsedAddr)) {
$rcpt[$parsedAddr] = '';
}
}

$rcpt = array_filter($rcpt);
$rcpt = array_unique($rcpt);
return $rcpt;
}

Expand Down
1 change: 1 addition & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$conf['smtp_host'] = 'localhost';
$conf['smtp_port'] = 25;
$conf['smtp_ssl'] = '';
$conf['smtp_ssl_allow_insecure'] = 0;

$conf['localdomain'] = '';

Expand Down
1 change: 1 addition & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$meta['smtp_host'] = array('string');
$meta['smtp_port'] = array('numeric');
$meta['smtp_ssl'] = array('multichoice','_choices' => array('','ssl','tls'));
$meta['smtp_ssl_allow_insecure'] = array('onoff');

$meta['auth_user'] = array('string');
$meta['auth_pass'] = array('password');
Expand Down
2 changes: 2 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
$lang['smtp_ssl_o_ssl'] = 'SSL';
$lang['smtp_ssl_o_tls'] = 'TLS';

$lang['smtp_ssl_allow_insecure'] = 'Allow insecure SSL';

$lang['auth_user'] = 'If authentication is required, put your user name here.';
$lang['auth_pass'] = 'Password for the above user.';

Expand Down
2 changes: 2 additions & 0 deletions lang/zh/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
$lang['smtp_ssl_o_ssl'] = 'SSL';
$lang['smtp_ssl_o_tls'] = 'TLS';

$lang['smtp_ssl_allow_insecure'] = '允许不安全的SSL';

$lang['auth_user'] = '如果需要认证,在这里输入您的用户名。';
$lang['auth_pass'] = '对应上面用户名的密码。';

Expand Down
8 changes: 8 additions & 0 deletions subtree/txtthinking/Mailer/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto

/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
1 change: 1 addition & 0 deletions subtree/txtthinking/Mailer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor/
composer.lock
.idea/
docs/
phpunit.xml
11 changes: 11 additions & 0 deletions subtree/txtthinking/Mailer/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php
sudo: false
php:
- "7.4"
- "7.3"
- "7.2"
- "7.1"
- "7.0"
- "5.6"
install: composer update
script: ./vendor/bin/phpunit --verbose
38 changes: 10 additions & 28 deletions subtree/txtthinking/Mailer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ A lightweight SMTP mail sender

```
$ composer require txthinking/mailer
# or
$ composer require txthinking/mailer:dev-master
```

### Usage
Expand All @@ -16,36 +18,16 @@ $ composer require txthinking/mailer
use Tx\Mailer;

$ok = (new Mailer())
->setServer('smtp.ym.163.com', 25)
->setAuth('', '') // email, password
->setFrom('You', '') //your name, your email
->setFakeFrom('heelo', 'bot@fake.com') // if u want, a fake name, a fake email
->addTo('Cloud', 'cloud@txthinking.com')
->setSubject('Test Mailer')
->setBody('Hi, I <strong>love</strong> you.')
->setServer('smtp.server.com', 25)
->setAuth('[email protected]', 'password')
->setFrom('Tom', '[email protected]')
->setFakeFrom('Obama', 'fake@address.com') // if u want, a fake name, a fake email
->addTo('Jerry', 'jerry@server.com')
->setSubject('Hello')
->setBody('Hi, Jerry! I <strong>love</strong> you.')
->addAttachment('host', '/etc/hosts')
->send();
var_dump($ok);
```
OR
```
<?php
use \Tx\Mailer\SMTP;
use \Tx\Mailer\Message;
use \Monolog\Logger;

$smtp = new SMTP(); // new SMTP(new Logger('Mailer')); # set logger to receive debug log
$smtp->setServer('smtp.ym.163.com', 25)
->setAuth('[email protected]', ''); // email, password
More [Example](https://github.com/txthinking/Mailer/tree/master/tests)

$message = new Message();
$message->setFrom('Tom', '[email protected]') // your name, your email
->setFakeFrom('heelo', '[email protected]') // if u want, a fake name, a fake email
->addTo('Cloud', '[email protected]')
->setSubject('Test Mailer')
->setBody('<h1>For test</h1>')
->addAttachment('host', '/etc/hosts');

$ok = $smtp->send($message);
var_dump($ok);
```
3 changes: 1 addition & 2 deletions subtree/txtthinking/Mailer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"erb/testing-tools": "dev-master",
"phpunit/phpunit": "~5.0",
"monolog/monolog": "~1.13"
},
"autoload": {
Expand Down
Loading