1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

How to Send Mails from Hosts that have mail function disabled - MAIL4EVERY1

Discussion in 'PHP' started by ManzZup, Jul 30, 2011.

  1. ManzZup

    ManzZup New Member

    What is MAIL4EVERY1?

    After long time, I got this very unusual idea to make something useful :D Basically I got fed up with my web host not allowing mail() feature and so MAIL4EVERY1. Mail4Every1 is a simple script that would allow any one to send emails even if the webhost allows the mail() or not or even it doesnt have a mail server at all. It is simply another function (zmail()) to sustitue for the default php mail() function.

    How it Works?

    It's just simple, no rocket science included :). What the script does is to use a server that has already enabled the mail() function to act as the mail server of your host.


    1. You call the zmail() function
    2. zmail() does a *hidden* AJAX call to another php script hosted in a host with mail() enabled
    3. The second host sends the message with the details given in the first one

    That's it!

    Lets begin the interesting part :D


    1. mailer.php - The official script which contains the zmail() function
    2. A host with mail() enabled - Now you think why on the earth I would not use that host without doing all those hard stuff. The reason is many reliable web hosting providers doesn't allow the use of the mail() function as it can be easily abused. But there are plenty of free web hosting sites to help you in the task of doing it. Ex: I use zymic.com [I AM NOT TELLING ANYTHING WRONG ABOUT THIS HOST, JUST FOR THE EXPLANATION I USE IT]. I dont get the mail() function unless I give $10. I simple don't want to be paying as I cannot afford :) so I use another free host like freehostingcloud as the second host and use this script to send my mails.
    3. mail.php - This one should be there in the second host to be called from the first
    Download the mailer.zip OR View Live Demo


    1. Download the zip file and extract, and you will get 3 files in the "zmail" directory. mailer.php, mail.php and jquery.js
    2. Upload mailer.php and jquery.js to web host from where you want to send mails.
    3. You need a free host that will allow to use the mail() function, I used the site freehostingcloud.com for mine. Make a new account there and upload the mail.php you found on the "zmail" directory.
    4. Now we need to call the zmail() function from another php script which will accept the POST data from a html form. You can find the index.php and mail2.php in the "demo" directory in the file you downloaded. Upload that to the SAME directory as before

      So we will make a simple a php script, it is just as calling the normal mail() function.


      include "mailer.php";

      $url "http://site.freehostingcloud.com/mail.php";
      NOTE: the usage of zmail() function;
      • $url - The path where the php script that do the actual mailing is [in the server where mail() is allowed]
      • $to - The reciever of the mail
      • $from - The sender's email [NOTE That some free hosting requires that the sender mail should be registered at the control panel first]
      • $name - The sender's name
      • $sub - The subject of the message
      • $msg - The mail content

      Now to call this script a little HTML form


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>#Project : Mail4Every1 ZONTEK</title>
      *****************************************<br />
      #PROJECT MAIL4EVERY1<br />
      *****************************************<br />
      <form action="mail2.php" method="post">
      <table border="0">
      <td>To :</td>
      <td><input type="text" name="to" /></td>
      <td>From :</td>
      <td><input name="from" type="text" /></td>
      <td>From Name :</td>
      <td><input name="name" type="text" /></td>
      <td>Subject :</td>
      <td><input name="sub" type="text" /></td>
      <td>Message :</td>
      <td><textarea cols="50" rows="15" name="msg"></textarea></td>
      <td><input type="submit" value="Send" name="send" /></td>
    5. Upload these to the same drectory where mailer.php is
    6. Now browse your zymic URL http://site.zymic.com/mailtest you will find a simple form. Put the details in there, make sure you have done the steps corectly and push the Send button. You will be redirected to the mail2.php and then a little loading like sign and then everything done!
    VIOLAAA!! :D
    you will recieve your mail SOON... :D

    Thats is basically the thing, but there are some things to be put

    4. PLEASE DONATE ME TO PAY FOR MY ELECTICITY BILL : :D (if you like to donate my paypal is manzzup@gmail.com)

    Attached Files:

  2. shabbir

    shabbir Administrator Staff Member

    I am not sure if I get the idea of MAIL4EVERY1. You anyway need a host that is using mail function and so this is actually not sending email without mail function but using a different server.

    I have few questions though.
    • How do you connect to second server? Do you use curl or anything like that?
    • Why not use smtp instead of mail function?
    • Is this not termed as spamming? Also does your mail come into inbox or goes into spam folder?
    • Why not use the hosting that provides mail function in the first place.
    • How do you handle the blacklisting of such free hosts?
  3. ManzZup

    ManzZup New Member

    Why not use the hosting that provides mail function in the first place?

    That's the one i was trying to clarify all along, it is like this. Many uses freehosting + a paid domain name these days. But most of these *free* hosting are not upto standard.
    ex: assume that host1 is a very reliable, ad free hosting service but no mail() enabled
    and host2 is a free service with all features but NOT reliable and even has ads
    In a condition like this the user would like to have a combination of both, which is unlikely to be given free. As a foundation to make this combination MAIL4EVERY1 is there. You can use host1 as your host while using the mail() of host2. Hope it is clarified.

    How do you connect to second server? Do you use curl or anything like that?

    It is done using an AJAX request as the use of sockets would be disabled as well

    Why not use smtp instead of mail function?

    Even smtp needs the underling mail() function that is for php. So even if you use a relayer or a script like phpMailer it wont work as the mail() disabled

    Is this not termed as spamming? Also does your mail come into inbox or goes into spam folder?

    NO, this is not spamming but abusing this service may lead to spamming as well [That i'm trying to make a solution of]. The delivery of the mail relaye COMPLETELY on the way of host2(as of the previous example). The one i showed here will deliver it to the inbox. But there are certain free ones that deliver it to spam as well. For this i will be developing the use of smtp relayer like google from the other end (host2) for reliable mail delivery :)

    How do you handle the blacklisting of such free hosts?

    This is another issue when relating to the script. but the blacklisting will be done with/without the script as anyone can abuse the mail() function if it is enabled. But as for its effect on the MAIL4EVERY1 script assure you that it would be minimal as you can easily change your mailing host (host2) from the script so that if one is blacklisted another can be used. AND i am trying to develop a paid server in the future (if i got enough $$$ :D) to make a free server available for the users of the script. If one i managed to provide this kind of a paid hoting for free ;
    ex: user1 buys paid hosting with mail() and make it available for another 100 users to use
    like that it can be developed but spamming will be a HUGE issue :(

    AND thank alot shabbir for asking these questions as it will remove the doubts of other and i was just unable to explain the system well untill you asked those :D
    thankx again
  4. shabbir

    shabbir Administrator Staff Member

    Thanks for clarifying all but one question because I think I was not able to explain that question properly.

    Now you are assuming that I am using the same server to send email using SMTP but normally SMTP is used on other server as well.

    Let me give you an example.

    Say I want to send emails from xyz.com and use external smtp server provider (Say Google) to send my emails and that way it does not matter if my xyz.com has mail enabled or not.

    You are actually trying to re-invent the SMTP system with PHP mail function. Why not use SMTP of Google from reliable host1 instead of using it through a chain of hosts which are anyway unreliable.

    Also one more fresh question.

    What happens when host2 suddenly stops the mail function after understand it is being spammed.
  5. ManzZup

    ManzZup New Member

    In your example, if the mail() is disabled in the hsot xyz.com, there's no way sending mails from the host. That means suppose you have a certain forum script that uses the mail() function to authenticate users by sending email after registration. If you use Google SMTP relayer, you have to have a script that would use the relayer and again the script would be using the mail() function. (Please correct me if i am wrong with that fact). Thus we again come to the first position, where the mail() is not a matter for sending the email.

    PS: as for my knowledge i dont know any other mean of using n exernal relayer within a script without using mail(), please correct me if I am wrong on that

    What happens when host2 suddenly stops the mail function after understand it is being spammed?

    That would cause an interruption but as i said in the Question "How do you handle the blacklisting of such free hosts?" it can be achieved by some various means which includes having a list of external mail domains or simply having one paid host and providing service to many. The provider can even take a small charge for the server so that there will be no loss for him.
  6. shabbir

    shabbir Administrator Staff Member

    Yes you are completely wrong in understanding the SMTP. You infact don't need to have any mail feature on your server to send emails using SMTP. Example can be your local PC which even can send emails using smtp. You are using external server to authenticate smtp and send emails.
  7. ManzZup

    ManzZup New Member

    using the smtp with the local machine is of course i do understand, but can you please direct me page which explains about doing the procedure on an external web host without mail()?

    i mean as i know there are basically 3 ways to send a mail using php

    1) using the default mail() function
    2) using an external extension like sendmail as the sender
    3) using sockets to connect to the SMTP server (SMTP direct)

    but what if ALL these are disabled?

    Or is there any other method i have missed?
    Last edited: Jul 31, 2011
  8. ManzZup

    ManzZup New Member

    however i am about to release the second version of the script with following additions

    1: use defualt mail()
    2. use direct socket connection
    3. use the above method (of using another server)

    to send mails
    so i would like to know whether there should be any other additional methods?
  9. shabbir

    shabbir Administrator Staff Member

    Everything is disabled on your server would also allow you to connect to other server if you have internet connectivity allowed on that server and you are allowed outgoing connections on smtp server port.

    I am not sure why you would like to have such script when SMTP server can get all done.
  10. ManzZup

    ManzZup New Member

    nope they wont allow ANY type of connection to an external source (even cannot use the header function :S)
  11. gpmcanada

    gpmcanada Guest

    it's good to be here thanks for sharing.
  12. ManzZup

    ManzZup New Member

    pleasure's mine :D
    and a new version is released, but i have to write a manual for it

Share This Page