
One of the things I find hard in developing a web application is using a library for sending email such as PHPMailer. I find it hard when used to send emails. Another thing I find hard is when sending emails in a localhost webserver. It would also cost me more and would take much time in setting up my own mail server. PHP’s mail function is also very useless in such testing ground.
If you are using a gmail account and want to use PHP’s mail function in your local webserver, here is a better way to relay an email to gmail. I am using backtrack 5 Gnome and the steps will also work for debian based distros. Follow the steps below,
Install ssmtp,
After installing ssmtp, open the configuration file.
Below is an example configuration to have it working, compare your existing configuration to what I have below and apply the changes
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. #root=postmaster root=[email protected] # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com #mailhub=mail mailhub=smtp.gmail.com:587 # Where will the mail seem to come from? rewriteDomain=icpep.org # The full hostname #hostname=tuxmobile hostname=[email protected] # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES AuthUser=[email protected] AuthPass=MyPasSW0rd007 FromLineOverride=YES mailhub=smtp.gmail.com:587 UseSTARTTLS=YES |
After the changes, you can now use PHP’s mail function
|
1 2 3 4 5 |
< ?php $message = "This is a test"; $message = wordwrap($message, 70); ?> |

