Answer the question
In order to leave comments, you need to log in
How to set up sending emails locally?
Hello. I am using openserver. How to configure the ability to send letters to an e-mail address? Now the letters are not coming. The essence of the question is not how to write such a script, but how to make letters go to the mail from the local server. Thanks to all))
Answer the question
In order to leave comments, you need to log in
Hey! Use for example mailchimp.com
You will send a request to their server, and it will send a letter - otherwise, probably nothing
If without openserver menus, then in php.ini as a mailer you can specify the path to the php script
and in the script something like this .
<?php
// Заглушка sendmail
// based at http://urths.com/blog/заглушка-sendmail/
$MailDir = __DIR__.'/log/'; // папка для сохранения писем
if (!is_dir($MailDir)) {
mkdir($MailDir, 0644);
}
$data = "";
$line = 'foo';
$f = fopen("php://stdin", "r");
while( !feof($f) AND ($line!='') ) {
$line = fgets($f,255);
$data .= $line;
}
fclose($f);
$data = str_replace("\r", '', $data);
$data = str_replace("\n", PHP_EOL, $data);
$i = 0;
$addon = '';
while ( file_exists( $fname = ($MailDir.'/'.date('Y-m-d-H-i-s').$addon.'.eml') )) {
$i++;
$addon = '-'.$i;
}
file_put_contents($fname, $data);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question