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

Email Library does not have an public test of connection function #3402

Closed
crustamet opened this issue Jul 24, 2020 · 11 comments
Closed

Email Library does not have an public test of connection function #3402

crustamet opened this issue Jul 24, 2020 · 11 comments
Labels
new feature PRs for new features

Comments

@crustamet
Copy link
Contributor

I always wanted to test different config connection for the Email Library if it works or not.
The thing is, i can do that with sending an message, but i don't want to send a message just to check if the connection is established.

I've searched already for some function to work with, but they are all protected functions so i can't use it out of the class.

I hope someone can implement this basic important function, with all three types of protocols. sendmail, mail, SMTP.

I know for the mail function it does not require any type of test, it will work for sure if the server has an emailing servicee.
The problem comes with sendmail and SMTP.
Sendmail the path can be changed. so i want to test this path.

SMTP has so many possible configurations along with a user and a password.
Whenever i set a connection i just want to test if the config is a valid configuration so i can save the configuration to the database and not send an email to check if the config is valid.

At least make a public function for the SMTP configuration to test it if not for all protocols.

@tangix
Copy link
Contributor

tangix commented Jul 27, 2020

Sending a test-email to the admin setting up the configuration? Many of the software packages I use do that.

@crustamet
Copy link
Contributor Author

crustamet commented Jul 29, 2020

But i don't want to send a message just to check if the connection is established.

I want to check the configuration if it is configured correctly then send an email test.

Anyway if an checker exists i don't see why you want to send a message just to check it, maybe only to check how it was sent.

@tangix
Copy link
Contributor

tangix commented Jul 29, 2020

Anyway if an checker exists i don't see why you want to send a message just to check it, maybe only to check how it was sent.

For example the mail-server may reject your FROM or TO addresses, something you probably won't get an error for until you actually try to send it. Personally, I'd say that testing email sending isn't done until you have the email in your inbox, but that's just my personal opinion.

@ivantcholakov
Copy link

Let say you have an application with an administration panel and a page "Self-Diagnostics". One of the widgets there might say "Your mailer server is enabled, but there is something wrong on your configuration - connection can not be established." + some technical details. Not a bad idea, epecially for publicly distributed applications.

There is a similar active issue for PHPMailer PHPMailer/PHPMailer#612 with some considerations.

@crustamet
Copy link
Contributor Author

In reply for Tangix, again you don't have to send an email just to check the connection even if FROM or TO addresses going to be rejected, i just need to verify the user and the password if it can connect to the emailing service that's all.

I saw something on stackoverflow and it is simple to implement, i just dont like to hardcode it, i just want to nicely been build in codeigniter 4 style, with all options considered.

$f = fsockopen('smtp host', 25) ;
if ($f !== false) {
	$res = fread($f, 1024) ;
	if (strlen($res) > 0 && strpos($res, '220') === 0) {
		echo "Success!" ;
	}
	else {
		echo "Error: " . $res ;
	}
}
fclose($f) ;

it is as simple as you see here. And you see you don't need the error message just a notice that it is an error somewhere...
No email sending.

@MGatner
Copy link
Member

MGatner commented Aug 22, 2020

If you'd like to open a Pull Request this seems like a nice addition. Keep in mind that the email class supports multiple handlers, which may have different needs for qualifying connection status.

@MGatner MGatner added the new feature PRs for new features label Aug 22, 2020
@crustamet
Copy link
Contributor Author

@MGatner i know man, i dont know how to use the pull requests, i would have done this already on other issues aswell.

Maybe i am going to learn this in the near future after i finish my work, i really have to finish first.

@MGatner
Copy link
Member

MGatner commented Aug 23, 2020

A great way to start is just using GitHub's interface. Since Email is a single file (at this point) it is very easy:

  1. Navigate to the file you want to change on GitHub
  2. Select "Edit this File"
  3. GitHub will prompt for you to make a new branch on your own fork
  4. Edit the file (or paste in your changes)
  5. Add a commit message and submit
  6. GitHub will prompt you to create a PR, which you should do and follow the checklist

That's it! I believe in you :)

@crustamet
Copy link
Contributor Author

Oh my god so easy man lol, never saw the EDIT option LOL

@kenjis
Copy link
Member

kenjis commented Dec 28, 2023

Does anyone still need this feature?

@lonnieezell
Copy link
Member

I'd say close it for now. We can always revisit if it becomes a higher priorityh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature PRs for new features
Projects
None yet
Development

No branches or pull requests

6 participants