Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

submitting a form

Posted on 2006-05-17
13
Medium Priority
?
216 Views
Last Modified: 2006-11-18
I'm looking for a PHP script that allows me to send to a list of emails in a TXT file on my server.

So inside the PHP script should have some type of code $fiile=['myemails.txt'] (I guess)

Thank You
0
Comment
Question by:melvinbrad20
  • 6
  • 6
13 Comments
 
LVL 1

Expert Comment

by:calibishie
ID: 16705121
mymails.txt // emails addr will be separated by ;
-------------------------------------------
addr1@domain.com;address2@domain.com; etc.....


script.php
--------------------------------------
<?

$emails = file_get_contents('mymails.txt');
$emailsArray = explode(';',$emails);

foreach ($emailsArray as $value) {
       
      $to = $value;
       mail(); //do the mail function here.

}


?>
0
 

Author Comment

by:melvinbrad20
ID: 16705189
can I make it a way where each email is seprated on a new line, instead of being seperated with a (;)
0
 
LVL 1

Expert Comment

by:calibishie
ID: 16705220
<?

$emails = file('mymails.txt');

foreach ($emailsArray as $value) {
       
      $to = rtrim($value, "\r\n");
       mail(); //do the mail function here.

}


?>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:calibishie
ID: 16705224
The above should allow you to have each email on a new line within yourtext file.
0
 
LVL 16

Accepted Solution

by:
dr_dedo earned 1000 total points
ID: 16705243
<?
$mail=file('emails.txt');
$subject="subject";
$Charset="Content-type: text/plain; charset=iso-8859-1\r\n";
$message="hi, this is message body";
$from ="Your name <you@domain.com>";

foreach ($mail as $to){
mail($to,$subject,$message,"MIME-Version: 1.0\r\n".
$charset.
"From:'$from'\r\n".
"X-Mailer:PHP/". phpversion());
}
?>
0
 

Author Comment

by:melvinbrad20
ID: 16705244
now, do I need any kind of SMTP server settings
0
 
LVL 1

Expert Comment

by:calibishie
ID: 16705254
SMTP server settings should be setup in you php.ini file on your server.
0
 

Author Comment

by:melvinbrad20
ID: 16705282
I'm not sure if I have a php.ini file......also, can I use a form to insert the subject and the message fields
0
 
LVL 1

Assisted Solution

by:calibishie
calibishie earned 1000 total points
ID: 16705312
Do you have full access to your webserver? Is it a windows or *nix server?

Yes you can use a form to insert the subject and message field


<form method="POST" action="script.php">
Subject: <input type="text" name="subject"><br />
Message: <textarea name="msg"></textarea><br /><br />

<input type="submit" value="Send Mail">
</form>

In your script message....

$message = $_POST['msg'];
$subject = $_POST['subject'];

0
 

Author Comment

by:melvinbrad20
ID: 16705329
yes, I have complete access to my server, I use CPanel
0
 

Author Comment

by:melvinbrad20
ID: 16705414
It work perfectly...I tested it out, and I recieved the emails so I'm guessing that my php.ini files are correct....

Thank You
0
 

Author Comment

by:melvinbrad20
ID: 16705417
thank both of u guys for your help
0
 
LVL 1

Expert Comment

by:calibishie
ID: 16705468
you could use ini_set("SMPT", "<SERVER_HOST_NAME>")
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question