Well, just a simple question regarding sendmail script.. I wonder how to import recipient list from file???
This is how default recipient variable looks like:
$recipient .= "example2@php.net";
$recipient .= "example3@php.net";
I don't want to enter emails one at the time like this, but to read them from file. So I guess $recipient variable need to be changed or connected with some other script... Someone told me that it could be done by conecting $recipient with this script, but I don't know how.... Here is that script:
fgets - Gets line from file pointer
EXAMPLE:
You could put 1 email address on each line of a text file,
then set the text file lines to an array using something like
$emails = file("filename.txt")
Then $emails['0'] would be the 1st address, $emails['1'] would be the 2nd etc.
You could use a loop to cycle through them then.
Why won't this work? I save it as mailer.php and run it through IE on a server(ex. www.server.com/mailer.php), but nothing.. It wouldn't send any emails... And it only has 3 emails in file..
<?
$recipient = "";
$contents = file("emails.txt");
foreach ($contents as $value) {
$recipient .= $value;
}
$subject = "Subject of the message";
/* message */
$message .= "The following email includes a formatted ASCII table\n";
$message .= "Day \t\tMonth \t\tYear\n";
$message .= "3rd \t\tAug \t\t1970\n";
$message .= "17rd\t\tAug \t\t1973\n";
/* you can add a stock signature */
$message .= "--\r\n"; //Signature delimiter
$message .= "My signature";
/* additional header pieces for errors, From cc's, bcc's, etc */
$headers .= "From: Od mene <my@email.net>\n";
$headers .= "X-Sender: <my@sender.net>\n";
$headers .= "X-Mailer: Microsoft Outlook Express 6.0\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: <me@emailt.com>\n"; // Return path for errors
/* If you want to send html mail, uncomment the following line */
// $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
/* and now mail it */
mail($recipient, $subject, $message, $headers);
It won't work because once the foreach loop is done, $recipient is going to equal something like "addressone@domain.comaddress2@domain.comaddress3@domain.com" What you are going to want to do is put the entire mail script in the foreach loop, and then set up the recepients like that... Also, concatenating to a string, before you define the variable can cause problems on some servers. ie ($message .= "whatever"; should possibly have a $message = ""; on a line before it)
Could you modify my script above, cause I am not very sure how to do what you said... Also, instead of writing $message .= "bla"; for every new line, is it possible to putt only one $message variable and then modify the text and lines from inside quotes? Include that in example too, if it is possible.. Please forgive me for my lack of knowledge..
Try this: (note that I didn't use the form script that you were using, but a varriation of mine, found here)
PHP Code:
<?PHP
## The lines below need to be edited...
###################### Set up the following variables ######################
# #
$emailfile = "file.txt"; #file that contains the email addresses
$subject = "Your subject here"; #set the subject line
$message = "This is where the email message goes"; #your message
$headers = "From: you@your.com"; #set the from address
# #
##################### No need to edit below this line ######################
Something is not right. I think it is with your code... I have 3 emails in my TXT file... First email is not delivered, second one is delivered but there is no FromIt says Nobody) or Subjectit is empty), and in the message box this is written:
I tested the code before I posted it with 2 email addresses. Please post your modified code. Also, it would be helpful if you attach the file you listed the email addresses in.
$emailfile = "emails.txt"; #file that contains the email addresses
$subject .= "Subject of the message";
$message .= "This is where the email message goes"; #your message
$headers .= "From: Od mene <moj@email.net>\n";
Nope, now it sends messages to all three emails, but only the LAST ONE from the list gets email in proper way... Other two get this... I used authentical code that is written last time...
From field: Nobody Subject: Empty Space
Subject: Subject of the message
From: Od mene <moj@email.net>
This is where the email message goes
All this is writtn in the message window...
I don't know... Try to upload to your server and execute the same script with same emails.. Maybe it is an error in my ISP sendmail() configuration.. Just change the Subject so I know that it is you....
Yap, I got all in perfect order.... So it gotta be my ISP's cofiguration error... Any way to fix this or use some other mailing program? This is my free space I was given with dialup. Is there a way to check if the right mailing program is installed?????
Anyway, more important now that everything is working... Is there a way to make a log file after the emailing has been done, that will log SENT and UNSENT emails...
Or, cool feature, but I don't think that this can be done... When sending, a popup window pops up(offcourse) and says
sending email 1 of 983
and changes as the email is sent... That is a cool way to find out a speed of sending...
Yes, must be a problem with the server, though a weird one, at that.
Depends on what you mean by "keep a log of sent email." You certainly could log each email that the PHP sends a message to, but I'm not aware of a way to check if the email bounced or not...
And, as far as telling you which email it is on, you'd be able to do it (though I'm not sure about in a popup). But, it might be to fast to really see anything...
Bookmarks