0

I am looking to create one email (example@domain.com) to forward to all email addresses in a database.

People can email to example@domain.com, and then that email would get blasted to a list of predefined email addresses. It would need to include support for attachments.

I realize this is not secure at all and leaves this email address open to anybody to use, but this is what our organization wishes to do.

What would be the best way to do this on a PHP server?

Thanks.

user2631256
  • 131
  • 1
  • 8
  • 2
    I think you'd rather set up a mailing list/mail aliases and just let the mail server handle it. – Joachim Isaksson Jul 29 '13 at 17:30
  • this is easier done with a mail forwarding service, maybe. If you do need this list to update from a database, use postmarkapp or some email receiving service to call your server when an email is received – SoWhat Jul 29 '13 at 17:31

5 Answers5

0

This can be achieved in PHP Server as you have to go in depth of following things:

  • Email Piping

  • Email Headers

  • MIME Email attachments

  • Mailing List Management

Vineet1982
  • 7,730
  • 4
  • 32
  • 67
0

While emailing to a lot of people in the way you mentioned is not a good idea...

You can use PHP's "mail" function:

$to      = "user1@domain.com, user2@domain.com"; //(Comma separated list of emails)
$from    = "noreply@domain.com";
$subject = "Hello";
$message = "Hello there!";

$headers = "From: ".    $from . "\r\n".
           "Reply-To: ".$from . "\r\n";
//send it
mail($to, $subject, $message, $headers);
George
  • 1
0
while($row = mysql_fetch_array($emails))
{
    $addresses[] = $row['address'];
}
$to = implode(", ", $addresses);

And then send mail using mail function ... mail($to, $subject, $message, $headers);

Ronak Patel
  • 390
  • 1
  • 3
  • 12
0

The way you have worded your query is a bit confusing but it seems you have a hosting server that is going to receive emails to a domain email. You then want to have those emails autoforwarded to a list of recipients. It looks like you want to investigate (given you mention sendmail) linux mail services and autoforwarding. You may be looking at postfix and possibly using procmailrc to trap and redirect incoming mail on your server.

I have done this with procmailrc before but it really depends on what service is handling the incoming mail.

There is no problem calling a CLI PHP script as suggested by @George to then read your recipients from the database and do the sending.

Arthur Nicoll
  • 391
  • 1
  • 2
  • 8
0

While Arthur's answer made sense and most likely would work, I ended up finding that my host had the feature I was looking for buried deep inside it. For those who were wondering, it is called discussion lists.

user2631256
  • 131
  • 1
  • 8