Jump to content
Larry Ullman's Book Forums

Setting Up Zend/mail On A Hosted Server


Recommended Posts

Larry,

 

I am looking into using a good php mail library/framework and am thinking about using Zend Mail. However, the instructions you gave for installing it with Composer are great, but only for a local server environment. How do I set this up on a hosted production server?

 

Also, I have heard good things about PHPMailer. What is your impression of it? I want to send both plain text and HTML embedded emails. I would really like to stay away from setting up complex dependencies on any preinstalled modules on the server. A stand alone class package that I could download and install myself would be preferred.

 

Thanks,

 

Matt

Link to comment
Share on other sites

Jonathan,

 

Thanks for responding! Ok, then I will probably go with phpMailer then. Also, I know this might sound like a ridiculous question, but is it ok to use the regular mail() function for a contact form? The reason I ask is that the email will not be sent to a user, and doesn't need any fancy formatting, so I thought it was probably just fine for that. I thought that there is no way security can be breached because I am formatting the mail in php and it will be sent to the admin (myself).

 

Also, when I was looking into phpMailer, almost every tutorial shows it using SMTP. I started reading about the different mail protocols and it seems like a very deep hole that I don't want to go down right now. The topic is very complicated (when it should actually be quite simple) and I would have to use a SMTP server like Postmark, which charges money after the first 1000 mails sent. Is SMTP worth using? What is wrong with standard Webmail?

 

Thanks again,

 

Matt

Link to comment
Share on other sites

I do something similar for some cron jobs I run. I just use the mail() function as I just need some info. Nothing fancy. So I am under the same impression as you on that front.

 

On a local host you can use your ISP SMTP. On my shared host Im pretty sure they have a SMTP available to use. If you use something like digital ocean that I have too I used Mandrill which I do reccommend. I think they allow you to send 12k free and it was a breeze to set up in general and it adds maybe 3-4 short lines of code to configure the mailer to use it.

Link to comment
Share on other sites

More and more I'd definitely recommend outsourcing the email handling on any legitimate, non-trivial site. It'll perform better, be more reliable, get more emails through to recipients, etc., etc. And, as Jonathon pointed out, they're free to very cheap for light uses. 

Link to comment
Share on other sites

Larry,

 

Thanks for the response! I did some research on the subject, but I just want to clarify.

 

1. SMTP is what I should be using for all email on my site.

 

2. I should outsource all my email handling to a site like Mandrill (both mail sent to users when they register or change their password, as well as mail sent to the admin account on my site when a user completes the contact form).

 

3). I should definitely use a professional mailer script like Zend/mail or PhpMailer.

 

Thanks for any help or advice you can give!

 

@Jonathan,

 

Thanks for recommending Mandrill. I looked at their site and while their is a lot you can do, it does seem to be what I'm looking for. I am not doing anything complicated, so I don't think I need to use the API, but just want to send simple emails. I found the following script which I think will work fine for my use case:

 

http://help.mandrill.com/entries/23737696-How-do-I-send-with-PHPMailer-

 

Is this script good for what I want to do?

 

Sorry to sound like a NOOB, but I am pretty new to the whole php email thing and I just want to make sure i am doing it right!

 

Thanks,

 

Matt

Link to comment
Share on other sites

Hi Matt

 

I used the same script or at least data based my own emails from that one mandrill has up. There is a tonne of stuff you can do but I too use Mandrill for the same kind of things you do and my newsletter.

 

I may be wrong here but because your mail goes through Mandrill they sort the SMTP out for you. I feel that's why I used it on my digital ocean account. Sure Larry could clarify.

Link to comment
Share on other sites

Yeah, I don't have SMTP/mail servers set up on my Digital Ocean droplet. In other words, my server cannot send out email. This means I don't need to run and maintain a mail server and I have less worry about my server being used for spam (and no worry about my IP address being blacklisted for spam). 

 

For all email sent by the site--to users or to me, I use Mailgun via an API request. Whenever an email needs to be sent, I send the data to Mailgun (through their API, via cURL) and they send the email. I wrote my own PHP class that acts as a wrapper to the cURL request. But a third party script is fine, too.

 

If I want my own email address on that domain and it doesn't have a mail server, I use a Google app ($5/month). You can all the benefits of Gmail (if you like Gmail) and, if you ever have problems with your server, you still have working email. That's big.

 

All of this is a little bit of complexity at first, but once established, it's so much more reliable. And when you consider how cheap Digital Ocean is, the slight added expense for third-party email is still a bargain.

 

By the way, the main reason I choose Mailgun is that it allows me to send out mass emails. Anyone that has bought a copy of "The Yii Book" can opt into this. When I have updates, they go out en masse through Mailgun. The cheaper alternatives don't offer this, but I'm paying a rate of $19/month for Mailgun to have this functionality. 

Link to comment
Share on other sites

@Jonathan,

 

Thanks for the response! I had a question about phpMailer, does it do any sanitizing for the headers to remove spam? I have heard that it is "safer" than using the standard mail() function, so I was wondering what it does besides having built in support for SMTP that makes it better.

 

Thanks

 

@Larry,

 

You are right about IPs getting blacklisted. I was doing a few tests with my GlobeDomain account and tried to send mail to my outside mail accounts. Almost all of them blocked the email completely (gmail did accept it, but put it in the "spam" folder). This is totally unacceptable!

 

I think that using a 3rd party mail server is probably the only solution to guarantee delivery! I won't be sending out the amount of email you are, but just want to make sure it gets delivered and doesn't cost a fortune.

 

Also, I keep hearing about Digital Ocean! What is all the excitement about?

 

Thanks,

 

Matt

Link to comment
Share on other sites

Digital Ocean...is obscenely cheap. Their servers are very fast. And it's no frills. You have to be able to do some server stuff yourself, though, because you don't get a nice control panel with simple buttons you can click. If you have the skills, then that's a benefit, too. I think the community is good, and there's lots of docs explaining most things. 

 

Basically, for 1/3rd of what I'm paying elsewhere for a VPS, I get a Digital Ocean VPS that performs better. I played around with Digital Ocean for a personal project just to see, and happily switched larry.pub to it. Will move larryullman.com there when I have the time!

Link to comment
Share on other sites

I'm not sure really tbh Matt. I didn't look too much into at the time.

 

Regarding Digital Ocean there is a thread in social that I started about it when I first started with them. Might be worth a read as a few people asked questions and there was some good questions that came up in there and some good answers.

Link to comment
Share on other sites

Thank you both for the help!

 

I am going to install phpMailer and see how it goes!

 

As far as Digital Ocean, it sounds good, but is it the kind of host you would put a business on, or is it more of a "casual" type of host?

 

Matt

Link to comment
Share on other sites

The only thing to be aware of with Digital Ocean is that you either need to be comfortable with command-line stuff and basic server admin (there are tutorials at Digital Ocean for it) or use a third-party management site (Jonathan uses one; Server Pilot, I believe).

Link to comment
Share on other sites

  • 2 weeks later...

@Larry - Thanks for the info about Digital Ocean! It sounds great!

 

@Jonathan - Thank you for recommending Mandrill! I got phpMailer and Mandrill set up without a problem and was sending mail after very little work!

 

Also, I wanted to ask you guys if we should use html email? I know Larry does in the book, but I found out that complex layout can be difficult (because of inconsistencies among mail clients) and that some clients mark html email as spam.

 

Thanks,

 

Matt

Link to comment
Share on other sites

Why not send both? I send html emails and I haven't noticed any major differences between clients. I think most companies send a html email now-a-days. Even if it's just a simple logo somewhere. Rather than a text based one.

 

Yes I found mandrill great for what I needed. You'll have fun with digital ocean too if you go down that route

Link to comment
Share on other sites

I'd say your users are the biggest factor in receiving HTML email or not. Is it something they'd expect? If you do send HTML email, either send very simple HTML or make sure it's well tested across multiple clients. Some mail services can help with this (e.g., Campaign Monitor has a testing and preview tool).

Link to comment
Share on other sites

  • 4 weeks later...

Larry,

 

Sorry for the late reply! Thanks for the advice!

 

I agree that the HTML should be simple, but I think users almost expect it nowadays. I have looked into this and I also found out about Campaign Monitor. I will try it!

 

Thanks,

 

Matt

Link to comment
Share on other sites

 Share

×
×
  • Create New...