1

I have web application, and I want to implementation email system. My web application is a social network: users receive email when users update status and any another user is commented to their status.

What is the best way to implement that? I have been implement email system after users is comment, then in the same time I'm sending email to their user. The second option to use a schedule to send email.

I am using PHP and SwiftMailer.

To clarify: should I directly sent email to users, or should I use a database to queue mail and send via cron?

halfer
  • 19,824
  • 17
  • 99
  • 186
viyancs
  • 2,289
  • 4
  • 39
  • 71
  • 1
    Two ideas: most importantly, use a library such as Swiftmailer. Secondly, queue emails in your database, so you can see what you sent to whom, and you can resend any that failed (say if your SMTP service goes down). – halfer Feb 27 '13 at 07:44
  • thanks for your answer, yes I am using swift mailer. did you know how to detection mail is sent sucessfully or not , so I can resend again if email is not sent successfully. – viyancs Feb 27 '13 at 07:59
  • I suggested using a library since you didn't mention it in your original question. Yes, I would use a queue. I should think SwiftMailer would raise an exception if it can't contact your SMTP server - catch that and flag it in the related database record. – halfer Feb 27 '13 at 09:05
  • I'm still not clear in my problem, library of send mail only detection wrong authentication and wrong email format, ect but not detection email is received in users side or not. ex rejected because 1) sender as spam 2) receiver is fake but correct format email – viyancs Feb 27 '13 at 09:30
  • I think [this](http://stackoverflow.com/q/5768389/472495) is what you need, found using [this search](http://stackoverflow.com/search?q=swiftmailer+smtp+reject). Bear in mind that you can only detect if the mail bounces when contacting the recipient's SMTP server - if it is accepted and later is junked (this isn't a bounce, even if it generates a reply to an easily-fakeable from address) then you can't detect this. – halfer Feb 27 '13 at 10:16

4 Answers4

0

Please try phpmailer library functions

kapil
  • 162
  • 5
0

You could also try PostageApp.

http://postageapp.com/

xaddict
  • 1,302
  • 3
  • 19
  • 38
  • I think the main problem not how to I am choice library for send mail. please look again in my question I have been update my question, thanks :) – viyancs Feb 27 '13 at 08:08
0

You can use inbuilt php function .Please visit the following link. http://php.net/manual/en/function.mail.php

bIgBoY
  • 417
  • 2
  • 12
  • I would tend to disagree: sending mail is actually quite hard. Attachments, multi-part html/text etc is much better done via a library. – halfer Feb 27 '13 at 09:06
0

My advice is to use a mailing service with an API, such as Sendgrid for large amounts of mails (>100 per day), and otherwise just use your php mailer of choice.

Sending mail via your own server has a couple of disadvantages, mainly related to getting blacklisted or marked as spam. This is because the other mail servers don't really know yours, and if suddenly a lot of mails start appearing, you look like a spambot.

To avoid sending a lot of mails at once, you also have to somehow queue the sending via batches, and for that you need cron jobs and such. Getting un-blacklisted is also not very easy, and simple domain changes will probably get you re-identified

Mailing services do relieve you of most of these problems, and are overall reasonably cheap. Learning the pitfalls of in-house mail solutions is usually too much for a single project, since it is a reasonably large topic.

Disclaimer: I do not work for any mail-sending service, I just happen to work in a place that had their domain blacklisted recently because of bad emailing practices.

Filipe Silva
  • 903
  • 1
  • 11
  • 12