S
S
Sergey Vasiliev2022-01-31 14:43:44
PHP
Sergey Vasiliev, 2022-01-31 14:43:44

How to send mail through PHP?

Hello. I have a project in PHP, at the moment sending emails there via mailgun, but the problem is that not everyone gets the emails due to the lack of encryption.
Now I have created a server on mail.ru smtp and tested it, everything works. Can I somehow integrate sending through it? I have a mail server on VDS, but it sends letters from the machine's domain, but I would like to through a remote SMTP server. Or maybe there are some libraries that do it automatically.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanatPHP, 2022-01-31
@FanatPHP

And again, for the umpteenth time, I am amazed at the orgy of impunity with which Roskomnadzor blocks the Internet for individual citizens of the country.
It would seem - took the tags and the title of the question, PHP E-MAIL MAIL SERVER How to send mail through PHP?
and copy-pasted into the address bar of your browser - what could be easier?
But the insidious police state does not sleep, and instead of the search results, it shows only a comrade major, menacingly shaking his finger.

F
Flying, 2022-01-31
@Flying

It is very strange that emails sent via Mailgun have poor deliverability. Such services, in particular, are used due to the fact that they normally implement all standard means of identifying senders, and also have a good reputation in terms of spam lists and other monitoring services.
Honestly, given the question, I would recommend that you just stay with Mailgun, and not try to create your own SMTP. The logic is very simple - a person asking such a question is unlikely to understand in detail how to ensure good delivery of letters in a manually assembled SMTP server, so the result will obviously be worse.
The description of the problem is also not very clear. "Because of the lack of encryption" of what? Perhaps you are just using something incorrectly or not configured?
Returning to the issue of libraries - I would lean towards Symfony Mailer . This is the "heir" of SWIFTMailer, which in turn, I think, was the most popular solution for this task in PHP, after all, more than 270 million downloads, PHPMailer has 10 times less .
It is clear that Symfony Mailer is well integrated into Symfony itself, but it is easy (though less convenient) to use on its own. Of the undoubted advantages of this approach is the ability to connect various transports (including the same Mailgun), which allows you to use different methods of sending letters without having to change the code. Symfony Mailer also integrates with Symfony Messenger, which in turn provides the mailer with the ability to send emails asynchronously with retry strategies, sending error tracking, etc.

N
Newto, 2022-01-31
@Newto

https://github.com/PHPMailer/PHPMailer
The library can send mail via remote SMTP, you just have to connect it and specify the access details to your mail server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question