K
K
Kanat2019-03-16 09:20:15
PHP
Kanat, 2019-03-16 09:20:15

What is a simple class for working with mail in php?

Tell me, is there a simple class for sending mail from the site? Just the title and body of the message. Of course, you can use the built-in mail () function, but somehow you don’t want to reinvent the wheel)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex-1917, 2019-03-16
@harasaev

You don't have to invent anything.
In any incomprehensible situation PHPMailer
Here is an example from the TOASTER))) YES, YES, there is also a search:
Как отправить письмо если mail() на сервере отключен?

require_once(JPATH_SITE.'/libraries/phpmailer/phpmailer.php');
        $mail = new PHPMailer;

        $sender = array($call_email, JText::_('modcallback_title'));

        $mail->isSMTP();
        $mail->SMTPDebug = 0;
        $mail->Host = 'ssl://smtp.yandex.ru';
        $mail->Port = 465;
        $mail->SMTPSecure = 'SSL';
        $mail->SMTPAuth = true;
        $mail->Username = $call_email;
        $mail->Password = "";//        Пароль
        $mail->setFrom($sender);
        $mail->addReplyTo($sender);
        $mail->addAddress($sender);

        $mail->Subject = 'subjec't;

        $mail->Body = 'Body';

        return $mail->send();

Well, if it’s no joke, then you don’t have to be fashionable and stylish youth everywhere, dragging a whole lib for the sake of one bunch and putting a plug in the form of an npm package on each hole)))
Your question is solved by a code of 87 lines, a squeeze from the mentioned lib, googled by the first line
$mhSmtpMail_Server = "ssl://smtp.yandex.ru";

D
Dmitry, 2019-03-17
@Compolomus

My bike is kind of simple
https://github.com/Compolomus/kmail

P
Pavel Mezhuev, 2019-03-16
@mezhuev

There is an option for those who have their own server (physical or virtual) and for whom the functionality of the built-in mail () function is enough.
Example for Yandex:

account default
host smtp.yandex.ru
port 465
from [email protected]
auth plain
user [email protected]
password Pa$$w0rD
tls on
tls_certcheck off

A complete list of parameters and their detailed description is available at man msmtp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question