Sarah Mandana
Sarah Mandana

Reputation: 1513

Sending emails in PHP

I am creating a website using bootstrap, HTML and PHP. Whenever I am sending emails via mail function, many recipients are unable to receive the email as my host told me that using a php mailer on a shared server like SH-2499957 is not a good idea. What other options do I have to send emails through PHP, that would not cause this problem?

Upvotes: 2

Views: 119

Answers (4)

Ehsan Khodarahmi
Ehsan Khodarahmi

Reputation: 4932

You can use Gmail (or any other SMTP-compatible email provider) with PHPMailer library. Consider that you can't use services like Gmail to broadcast a large number of emails.

Upvotes: 1

WillS
WillS

Reputation: 362

Try an external service like SendGrid. I know that SendGrid provides a PHP library for easy integration as well as through SMTP and a web API. They also provide 12,000 free emails per month.

SendGrid example:

// using SendGrid's PHP Library - https://github.com/sendgrid/sendgrid-php
$sendgrid = new SendGrid($api_user, $api_key);
$email    = new SendGrid\Email();

$email->addTo("[email protected]")
      ->setFrom("[email protected]")
      ->setSubject("Sending with SendGrid is Fun")
      ->setHtml("and easy to do anywhere, even with PHP");

$sendgrid->send($email);

From https://sendgrid.com/

Other alternatives include MailChimp, RailGun, AWS SES, and MailJet.

Upvotes: 2

jaggedsoft
jaggedsoft

Reputation: 4038

I just signed up for Mailgun and it's a great resource for developers. 10,000 free emails per month, easy setup, great API, one less attack vector on your server, and your outgoing emails are way less likely to go to spam. I have an existing mail server that works great but I'm in the process of switching over because mails sent through the cloud tend to have a higher open rate.

Mailgun Example for PHP:

$mailgun->sendMessage("mail.example.com",[
'from'    => 'Your Company <[email protected]>',
'to'      => 'Excited User <[email protected]>',
'subject' => 'Hello World',
'text'    => 'Testing some Mailgun awesomeness!']);

Upvotes: 1

Parthapratim Neog
Parthapratim Neog

Reputation: 4478

Use the Mandrill API, you can track your mails(Sent, Bounced, Delivered etc.), statistics and all. Add Templates with Ease. Check the documentation here

Upvotes: 1

Related Questions