/    Sign up×
Community /Pin to ProfileBookmark

using database and Mail()

I am pretty green when it comes to PHP and mySQL but am trying to make a conscious effort to self teach. I have started what I hope is on the right path to creating function in php that uses email address in a array from a database to send emails. If anybody could point me in the correct direction of what I am doing wrong that would be great.

[CODE]
<?
//connect to database
// query database for column ’emails’

//creat an array from email address in database… not sure how to do this…….

$subject = ‘mail’;
$message = ‘this is a test eamil’;

//add headers

count = email_array.length;

for (i = 0; i < count; i++){
$email_adress = email_array[i];
mail($email_address,$subject,$message);
}

?>[/CODE]

I am sure there has got to be a tutorial out there just not having much luck in finding one so thanks ahead of time for any help.

denoteone.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ss1289Jan 17.2008 — [code=php]
//use mysql_connect() function
//use mysql_query() function for getting 'emails'

$subject = 'mail';
$message = 'this is a test email';

while($result = mysql_fetch_array($query_result))
{
$email_adress = $result["emails"];
mail($email_address,$subject,$message);
}

?>[/code]

$query_result is what mysql_query() returns.

mysql_fetch_array() returns an associative array of the tables columns
Copy linkTweet thisAlerts:
@DenoteoneauthorJan 18.2008 — Running a while loop until the array does not contain an email address makes sense but is it the most efficient way to send out newsletters? I know there is software out there but is seems like it should be pretty straight forward to develop yourself......
Copy linkTweet thisAlerts:
@ss1289Jan 20.2008 — Running a while loop until the array does not contain an email address makes sense but is it the most efficient way to send out newsletters? I know there is software out there but is seems like it should be pretty straight forward to develop yourself......[/QUOTE]
No it's not really efficient at all if you sending out huge bulks of emails. Have you looked at the phpMailer class.

This will probably help you.

http://www.schogini.com/articles/Sending-Emails-with-PHP.html

Check out the send() function and the end of this article.
Copy linkTweet thisAlerts:
@DenoteoneauthorJan 21.2008 — ? Thank you SS1289.

I think I will take a look at the source for the free bulk mailers.
×

Success!

Help @Denoteone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...