O
O
Outsider V.2015-03-03 01:54:07
PHP
Outsider V., 2015-03-03 01:54:07

The simplest way to send email from PHP?

There is a banal task: to send a registration script a link to activate the account to the user's mail.
I registered the [email protected] soap with the host, I climb into the PHP settings - and there in the mail() settings there is no SMTP password (how can you send mail without a password?!).
I dug in Google - there are some terrible gadgets, canvases of code for the banal sending of letters.
In general, is there some simple way in the latest PHP (in code less than one page) to send an email with a link to the user? Can I tweak something in the hosting settings (Hostinger) so that PHP scripts can send the mail () function from the [email protected] address? Otherwise, now letters are sent, but from a terrible address like [email protected] . And wordpress, by the way (when I installed it), sent it from this hosting on behalf of [email protected] .

ini_set('sendmail_from', '[email protected]') doesn't help :/

Thanks.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deodatuss, 2015-03-03
@Audiophile

$to      = '[email protected]';
$subject = 'the subject';
$message = 'Клиент '.$_REQUEST['user_name']. "\r\n" .
            'Skype:'.$_REQUEST['skype']. "\r\n" .
            'Телефон:'.$_REQUEST['phone']. "\r\n" .
           'Сообщение:'.wordwrap($_REQUEST['message'], 70, "\r\n");
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

$headers line. It worked for me

U
uyrij, 2015-03-05
@uyrij

It all depends on how the sendmail Hoster is configured, or rather the MTA (mail tansport agent) if configured and working, then calling the nix mail () will be enough. But often hosters do not allow using sendmail to reduce spam, because anyway, what you send via mail (_) will not even reach spam - it will be beaten right away. So go php smtplib, smtp class as a good option
phpmailer.worxware.com PHPMailer continues to be the world's most popular transport class, with an estimated 9 million users worldwide. Downloads continue at a significant pace daily

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question