How to send emails with my own email server installed locally - php

I have installed my mail enabled professional copy on the same server as php is installed (and wordpress) and I want to use the mail server when people enter emails forms etc.
I started with looking on simple email scripts but they all have failed and I have been googling for at least 8-9 hours on different solutions on scripts with sendmail, scripts using gmail, and lots of options that almost all require PEAR or some other solution - and I have thrown in the towel before I start tearing my hair out in frustration..
So Now I want to go with this option as it’s simpler for me and I do already own a license to mail enable.
How can I accomplish this?
I have the newest version of php available... Server is a Windows server 2003 ENT with IIS 6 installed and MySQL server/wordpress.
I am not a programmer - just a "normal" guy.. I know to get around with computers - most of the time - but coding Is like greek to me! (Which in this case might be my Achilles heel)

Try using PHPMailer or SwiftMailer.
These libraries make it trivial to configure your mail server to send emails with.
Mailenable should provide you with a smtp server and credentials.
Here's an example with phpmailer :
http://phpmailer.worxware.com/index.php?pg=examplebsmtp

Related

How to test PHP send mail on local server with MAMP Pro

I have a small web form that on submission triggers a mail script that sends an email to the address given to verify their email address.
I want to test this on my local server using MAMP Pro. I am totally confused from the info I have sourced that holds different advice and requirements.
I use Dreamweaver (DW) with WebAssist (WA) extensions to build my PHP scripts and when I contacted WA support to ask how to enter the correct settings with their DW plugin to work with MAMP pro they told me..
To have your localhost send email you need to install a local SMTP server configured for email relay.
If you want to use a remote smtp server you would likely have to use the PEAR mail option for authentication.
This has thrown me as I can't see anywhere in any MAMP Pro documentation about having to install SMTP servers and I know nothing about PEARL.
The following Blog makes it sound simple..
http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html
But it obviously isn't as I have tried these Postfix settings with know joy.
I have also seen this post..
Test emails locally with mamp
..that gives a method using gmail but I just can't make sense of it as It appears that the MAMP interface may have changed since this was written.
Plus I am not familiar with using Terminal.
If anyone can shed some light on this to point me in the right direction I would be most greatfull
You can use Mailhog to achieve this. I wrote a tutorial on Medium.
Install mailhog using Homebrew (if you don't have Homebrew installed, check out the instructions here: https://brew.sh/):
brew install mailhog
Open MAMP Pro and go to the “Postfix” tab. Make sure the checkbox next to “Include Postfix service in GroupStart” is checked.
Use these setting for Postfix:
Fill in your domain name in the field “Set domain of outgoing e-mails to:”
Check “Use a Smart host for routing”
“Server name:” is 127.0.0.1:1025 (this is the SMTP port Mailhog uses)
Set “Authentication” to “none”
Go to http://127.0.0.1:8025/ in your browser to see the mails sent by PHP.

Sending emails using XAMPP and PHP using Mac Yosemite

I am really confused on where to start with sending emails. I have search the web but the amount of content available for different packages and softwares has really confused me. I was wondering if anyone here had a simple or knows of a simple tutorial of how i can send an email using xampp.
Im new to using local host and so far have only used MySQL and Apache from xampp to load and view my php files for an application.
I would really appreciate it if anyone could help me start setting up XAMPP to send emails when i use the php.
Some sites suggest a separate server is needed for emails such as PHPMailer while others suggest a few config changes need making like changing in the php.ini files which I'm very cautious to change incase my whole xampp crashes!
is this link any good? http://www.websnippetz.com/2013/01/send-email-from-xampp-localhost.html
Many are using SendMail package with XAMPP but i can't find a download for that.
anyone tried anything which worked for them?
please help a very confused developer guys!
Some sites suggest a separate server is needed for emails such as PHPMailer while others suggest a few config changes need making like changing in the php.ini files which I'm very cautious to change incase my whole xampp crashes!
PHPMailer is not a server it is a library. People often recommend using a Mail library because the built mail functions are very low level and hard to work with. Because they are modeled after using sendmail from the commandline.
If you want to send via SMTP, use attachments, or other things it can be difficult or impossible to do with mail() directly.
Personally I recommend using SwiftMail over PHP mailer. IMO, it's more modern, easier to use, and has a better API, and depending on which PHP F/OSS projects you are used to using or contributing to its more common and the standard.
Overall there are 2 parts to sending mail from PHP:
Setup of the actual mail server on a system (local or otherwise)
The configuration of PHP to use that mail server.
To setup the mail function you need to install and configure a mail server locally in order to fulfill item (1). This should already be included and set up on OSX. So to fulfill item (2) you need to configure PHP via the INI to use that mail server by changing the sendmail_path.
Now if you want to use a library, which I recommend you need to get that source into your project and then use it appropriately. For the example we will use SwiftMailer, with SMTP transport via a gmail account:
require_once 'PATH/TO/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.googlemail.com', 465, 'ssl')
->setUsername('user#gmail.com')
->setPassword('secret');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('My SMTP Message')
->setFrom(array('john#doe.com' => 'John Doe'))
->setTo(array('receipient#domain.com', 'other#domain.com' => 'A name'))
->setBody('Plain Text Message Body');
$mailer->send($message);
To send emails from your localhost your need an Email-Server like postfix or Exim or you send your E-Mails over SMTP what is described on that site from your link.
The easiest way is to use an abstraction layer like Swift Mailer
http://swiftmailer.org/docs/sending.html
Here you have a lot of possibilities to send E-Mails. Another solution is to install a local Mailserver and fetch all sending E-Mails. In MAMP Pro for example you have an integrated Mailserver.
http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html

SMTP Authentication using PHP Script without using Third Party Software

I am writing a website which will automatically generate emails to users on special occasions (e.g. the activation email after user registration). The problem is, SMTP authentication is required, but the website will be hosted on a web hosting service, which does not have Pear Mail installed. I have read many articles on the Internet, saying that either Pear Mail, PHPMailer or SwiftMailer is required for SMTP authentication. As I do not have the authority to install any of them, what can I do in the PHP scripting level if none of the above exists?
A side question is, if Pear Mail, PHPMailer or SwiftMailer is a PHP library, does it mean we can actually perform SMTP authentication by writing our own PHP code?
Added: This link (http://www.webdeveloper.com/forum/showthread.php?233847-A-Way-to-Send-SMTP-Mail-w-o-PEAR) seems to have provided a solution, but when I tried, nothing happened (no email was sent). Does it really work?
Classes like PEAR Mail, SwiftMailer of PHPMailer are all just PHP scripts, no different to your own scripts, so if you can run PHP at all, you can install and run any of these libraries without any special privileges. You don't even need shell access on your host - run the pear installer, or download the package on your dev machine, uncompress it, then upload the PHP files along with your own scripts. You only need to make sure your include paths are working for whatever location you choose to put them.
The installation mechanism described in the documentation is preferable as you can be sure it's putting everything in the right place, handling dependencies, versions etc, but so long as scripts are readable and accessible to PHP it doesn't matter how they get onto the server.
If you're lucky, you may be able to run the pear installer in your shell account, where it would hopefully install pear packages somewhere accessible to you.

Testing website mailing locally

I'd like to test password recovery and similar email related features for a website.
I'm using PHP (cakePHP framework) and the syntax seems easy enough but I'm unsure of the email server setup.
I've looked around for a good tutorial but they aren't specific enough.
What is a quick and easy mail server to use locally? also... some initial steps to start up would be appreciated.
Test Mail Server Tool
xampp comes with a smtp server for sending mails from localhost, check out http://www.apachefriends.org
I've had good success with SMTP4DEV on a Windows box. It is open source.
You can see recent messages fairly easily with this tool. All it requires is that in your application you use localhost as the SMTP server.
From what I remember PHP has a config file has a entry for the SMTP server. You can get a local SMTP server and point ini for PHP to localhost.
On Windows Microsft Internet Information Server would have SMTP, I think even client will have an SMTP relay (may not be a full server however). or I am sure you can find numeros free SMTP server.
You could look at Post Case although I don't believe it is now (currently) free - it used to be, or you could look at Hamster 2.1 which is free, and then there is hMailServer 5.x.

Has Anyone Here ever tried PEAR

Hi I have been reading alot of articles adoring the PEAR mail package and it seems like PEAR is something I need to try out.
I am interested in setting up a full mail server, similar to a conventional SMTP mail service; which incorporates mail queuing, resending with a backend database etc. My impression is that PEAR can do this but can its service be used with mail clients like outlook to send mail, just as how any any smtp server daemon can where one would enter a portnumber, server name and/or security protocol?
Thanks
No, PEAR isn't going to magically solve these problems for you.
PEAR is a collection of PHP classes that are meant to solve common problems faced by PHP users. The Mail packages offer code for interacting with different parts Email systems. They do not contain code for creating email systems from scratch.
For example, form the Mail_Queue documentation
The Mail_Queue class puts mails in a temporary container, waiting to be fed to the MTA (Mail >Transport Agent), and sends them later (e.g. a certain amount of mails every few minutes) by >crontab or in other way.
The MTA in this case in sendmail, postfix, etc.
Another example, from the Mail_Mbox documentation
It can split messages inside a Mbox, return the number of messages, return,
update or remove an specific message or add a message on the Mbox
Incorrect use of "an" aside, you are using this to read existing MBOX files, and not caring how they got there.
The Mail package is about interacting with existing mail systems, NOT creating replacements. You'll still need to understand how all those email systems work to create a "full mail server, similar to a conventional SMTP mail service". If you're doing this because you want to learn how email systems work, have at it. If you're doing this because you thing this will give your business some leg up in the email game, I laugh and say "good luck with that"
PEAR is a repository for lots of libraries. Some of them deal with mailing.
PEAR's Mail class is designed for sending mail only. It is not designed as an implementation of an SMTP server.
Pear Mail is an SMTP sender aka client, not an SMTP server. Although it's entirely possible to write server (any kind of server) in php that doesn't mean that writing an SMTP server yourself is necessarily a good idea as it requires quite some expertise to do it right (spam anyone?). If you want to see an SMTP server implemented in a scripting language, go have a look at Lamson, written in Python by Zed Shaw.
And while you're there, do read the About page. This quote says it all
However, as great as Lamson is for
processing email intelligently, it
isn’t the best solution for delivering
mail. There is 30+ years of SMTP lore
and myth stored in the code of mail
servers such as Postfix and Exim that
would take years to replicate and make
efficient. Being a practical project,
Lamson defers to much more capable
SMTP servers for the grunt work of
getting the mail to the final
recipient.
It seems to me that PEAR's MailQueue package may address your needs.

Categories