Valhalla Legends Archive

Programming => Web Development => Topic started by: warz on June 15, 2006, 10:16 AM

Title: Needing an email script
Post by: warz on June 15, 2006, 10:16 AM
Does anyone know of any scripts out there that can send mass email messages from your website? I'm not sure if PHP can do this, or not. What I'm going to be doing is allowing users to sign up for certain "groups" and allow members of this group to 'blast' emails to everyone in the group. I'm not sure if anyone is signed up for Yahoo!'s group messages, or whatever, but it'll be similar. It's kind of like a forum via email - sort of.

Anywho, I just need to be able to send emails (preferably able to send to multiple recipients at once). PHP preferred.
Title: Re: Needing an email script
Post by: Ender on June 15, 2006, 12:52 PM
PHP can do this very easily with the mail() function. And it can send mail to multiple recipients at once.

EDIT:

Getting a script for it is pointless. Just do it yourself. It's only a few lines of code.

e.g.:

<?phpfunction tryEmail($from, $to, $subject, $body) {	if (empty($from) || empty($body) || empty($to) || empty($subject))	     ...	$headers = "From: $from" . "\r\n" ."Reply-To: $from" . "\r\n" . 'X-Mailer: PHP/' . phpversion();	$ok = mail($to, $subject, $body, $headers)         if (!$ok) {             ...        }}?>



If you want to send it to multiple recipients at once, then you can make the $to string "user1@hosting, @user2@hosting" etc.


Title: Re: Needing an email script
Post by: warz on June 15, 2006, 01:35 PM
Ah, I did not know it was this easy.
Title: Re: Needing an email script
Post by: Grok on June 15, 2006, 08:28 PM
Quote from: Ender on June 15, 2006, 12:52 PM
Getting a script for it is pointless. Just do it yourself. It's only a few lines of code.

Encapsulation and reuse are both good reasons to wrap things up in a class or module.  Even if a module does very little, hiding the implementation details frees the programmers from having to know even those.