Php Email/database Troubles, Please Help Me Out. - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Php Email/database Troubles, Please Help Me Out. (1156 Views)
| Php Email/database Troubles, Please Help Me Out. by cmon(op): 11:41am On Nov 04, 2008 |
Now here's the scenario; I have a database of registered users, with their email addresses. I'm about to create a newsletter system where emails are extracted from the database and a loop is used in sending the emails to the users. I created the script for sending it but it doesn't seem to send the emails. Running through the script, there are no errors so I don't even know how to debug it. I know there's supposed to be an array involved by it's giving me so much headaches. Does anybody have a resources for such problems? |
| Re: Php Email/database Troubles, Please Help Me Out. by cmon(op): 12:18pm On Nov 04, 2008 |
The problem is solved. It's just the normal "do-While" loop. Thanks for viewing anyway. |
| Re: Php Email/database Troubles, Please Help Me Out. by yawatide(f): 12:19pm On Nov 04, 2008 |
It is always good when we solve our own problems - it further cements what we have just learned. ![]() |
| Re: Php Email/database Troubles, Please Help Me Out. by cmon(op): 12:57pm On Nov 04, 2008 |
@yawa, You can say that again ![]() However, there's another problem ![]() Now I can send the mails to emails in my database. But the server fixes the "from" field of the email sent as 'domain@eclipse.websitewelcome.com'. How do I change this to something like "Our Support Team". Get what I mean? |
| Re: Php Email/database Troubles, Please Help Me Out. by kehers(m): 2:29pm On Nov 04, 2008 |
Create ur own custom From header this way: $headers = "From: mail@ursite.com\r\n";//or Ur site <mail@ursite.com>But then as I always advise, using mail() inside loops is not always advisable because it opens and closes the mail socket in each call. Use a mail class instead. |
| Re: Php Email/database Troubles, Please Help Me Out. by Nobody: 7:51am On Nov 05, 2008 |
kehers:Thats not true in this case Here is an excerpt from the phpmailer class public function Send() {the first function ends with an abstraction that should use your chosen method of sending the mail the second function is just one of the method of sending the mail and you can see where the port was opened in bold now look at how users are expected to call the class $mail->Send() so if you plug that inside a loop, you will still end up opening and closing the sockets with each call to send() even though the class has been initialized |
| Re: Php Email/database Troubles, Please Help Me Out. by cmon(op): 12:50pm On Nov 05, 2008 |
@kehers, Exactly what I wanted. All problems now solved. Thanks y'all. |
| Re: Php Email/database Troubles, Please Help Me Out. by kehers(m): 4:15pm On Nov 05, 2008 |
@webdezzi Tnx for taking ur time to check out d class nd not just take my word for it. I purposely didnt want to mentn phpmailer but now that u av, fine. Phpmailer offers 3 methods for mailing- php mail, smtp and sendmail (popening mail path). For loops i'd recommend smtp. But not just that. D SMTPKeepAlive variable should be set to true. Here: $mail->new phpmailer();let me knw if u com up wit other tns and proof me wrong where neccessary. |
| Re: Php Email/database Troubles, Please Help Me Out. by Nobody: 7:01pm On Nov 05, 2008 |
i think i understand what you meant, if i am correct, the port remains opened and it is kept alive while mail is being sent, that makes more sense I think if the port is opened from the constructor level, i should still remain opened throughout the lifetime of the object |
| Re: Php Email/database Troubles, Please Help Me Out. by kehers(m): 8:55am On Nov 06, 2008 |
if i am correct, the port remains opened and it is kept alive while mail is being sentYup, u are correct. By the way, you can as well tweak the SendmailSend method (function) as well so that the opened sendmail socket is not closed till you do so explicitly. This is done by removing the pclose part and putting that in ur own custom method. |
| Re: Php Email/database Troubles, Please Help Me Out. by yawatide(f): 1:10pm On Nov 06, 2008 |
php.net is your friend ![]() |
I Need An Email Database Of Young Working Class Peopl In Lagos • Webmasters Please Help With This Adsense Troubles • Sms To Email/database System • 2 • 3 • 4
How May I Help You On Php Language, I'm A Php Guru? • I Need A Guide On How To Develop A Bandwidth Management System • I'm In Need Of Execellent Web-designer



