T
T
test-cats2019-07-18 10:25:18
open server
test-cats, 2019-07-18 10:25:18

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

3 answer(s)
A
Anton, 2019-07-18
@test-cats

5d301ff1aa3c1685705202.png

E
eternalfire, 2019-07-18
@eternalfire

Hey! Use for example mailchimp.com
You will send a request to their server, and it will send a letter - otherwise, probably nothing

S
Stalker_RED, 2019-07-18
@Stalker_RED

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 .

I used to tweak it a little
<?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 question

Ask a Question

731 491 924 answers to any question