Best way to send emails

Discussion in 'PHP' started by Tavicu, Jul 30, 2010.

  1. #1
    hello,

    i'm working on a CMS and I got to the point where you have to send emails, at which point I blocked.

    I tried various ways to send emails and reach the inbox in Gmail and Windows Live or Yahoo but I failed.

    All along I need a plugin that supports sending emails with normal and SMTP.

    I have a host from godaddy where I try to send, host to me and left a bitter taste when it comes to emails.

    Can recommend someone a script or a way to send emails as ok and reach the inbox of your favorite:))


    Thanks in advance.
     
    Tavicu, Jul 30, 2010 IP
  2. RoscoeT

    RoscoeT Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
  3. Tavicu

    Tavicu Active Member

    Messages:
    120
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #3
    Last edited: Jul 30, 2010
    Tavicu, Jul 30, 2010 IP
  4. zuhairtaha

    zuhairtaha Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    this is the best way I found and use it alway
    copy this code and then change my email : to your email
    and you can use the same page or include it in php like: <?php include('email.php') ?>
    don't forget to save it with *.php


    <?php
    extract($_POST);
    $sendto_email = "zuhairtaha@hotmail.com";
    $checkdomain = "yes";
    $lang_title = "Send an email";
    $lang_notice = "Fill in the form to contact us by email. All fields are required";
    $lang_name = "Your name";
    $lang_youremail = "Your email";
    $lang_subject = "Subject";
    $lang_message = "Message";
    $lang_confirmation = "Enter validation code";
    $lang_submit = "Send email";
    $lang_error = "Your email has not been sent, the following errors were found:";
    $lang_noname = "You did not enter your name";
    $lang_noemail = "You did not enter your email address";
    $lang_nosubject = "You did not enter a subject";
    $lang_nomessage = "You did not enter a message";
    $lang_nocode = "You did not the validation code";
    $lang_wrongcode = "You entered the validation code incorrectly. Please note that it is case sensitive";
    $lang_invalidemail = "The email address that you entered appears to be invalid";
    $lang_sent = "Your email has been sent. The following message was submitted:";
    $input_width = "300px";
    $title_align = "left";
    $title_css = "font-weight: bold; font-size: 120%;";
    $error_colour = "red";
    $showlink = "yes";


    if (empty ($senders_name))
    {
    $error = "1";
    $info_error .= $lang_noname . "<br>";
    }
    if (empty ($senders_email))
    {
    $error = "1";
    $info_error .= $lang_noemail . "<br>";
    }
    if (empty ($mail_subject))
    {
    $error = "1";
    $info_error .= $lang_nosubject . "<br>";
    }
    if (empty ($mail_message))
    {
    $error = "1";
    $info_error .= $lang_nomessage . "<br>";
    }
    if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $senders_email))
    {
    $error = "1";
    $info_error .= $lang_invalidemail . "<br>";
    }
    if (empty ($security_code))
    {
    $error = "1";
    $info_error .= $lang_nocode . "<br>";
    }
    elseif ($security_code != $randomness)
    {
    $error = "1";
    $info_error .= $lang_wrongcode . "<br>";
    }
    if ($showlink != "no")
    {
    $link = "<a href='http://www.meralinttrading.com/index.php?t=5'>go back</a>";

    }
    if ($error == "1")
    {
    $info_notice = "<span style=\"color: " . $error_colour . "; font-weight: bold;\">" . $lang_error . "</span><br>";

    if (empty ($submit))
    {
    $info_error = "";
    $info_notice = $lang_notice;
    }

    function Random()
    {
    $chars = "ABCDEFGHJKLMNPQRSTUVWZYZ23456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;
    while ($i <= 4)
    {
    $num = rand() % 32;
    $tmp = substr($chars, $num, 1);
    $pass = $pass . $tmp;
    $i++;
    }
    return $pass;
    }
    $random_code = Random();
    $mail_message = stripslashes($mail_message);

    print "<form name=\"BELLonline_email\" method=\"post\" style=\"margin: 0;\" action=\"\">
    <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
    <tr align=\"$title_align\" valign=\"top\">
    <td colspan=\"2\"><span style=\"$title_css\">$lang_title</span></td>
    </tr>
    <tr align=\"left\" valign=\"top\">
    <td colspan=\"2\">$info_notice$info_error</td>
    </tr>
    <tr valign=\"top\">
    <td align=\"right\">$lang_name</td>
    <td align=\"left\"><input name=\"senders_name\" type=\"text\" class=\"mailform_input\" id=\"senders_name\" style=\"width: $input_width;\" value=\"$senders_name\" maxlength=\"32\"></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_youremail</td>
    <td align=\"left\"><input name=\"senders_email\" type=\"text\" class=\"mailform_input\" id=\"senders_email\" style=\"width: $input_width;\" value=\"$senders_email\" maxlength=\"64\"></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_subject</td>
    <td align=\"left\"><input name=\"mail_subject\" type=\"text\" class=\"mailform_input\" id=\"mail_subject\" style=\"width: $input_width;\" value=\"$mail_subject\" maxlength=\"64\"></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_message</td>
    <td align=\"left\"><textarea name=\"mail_message\" cols=\"36\" rows=\"5\" style=\"width: $input_width;\" class=\"mailform_input\">$mail_message</textarea></td>
    </tr>
    <tr align=\"left\" valign=\"top\">
    <td width=\"100\">$lang_confirmation</td>
    <td><input name=\"security_code\" type=\"text\" id=\"security_code\" size=\"5\">
    &nbsp;&nbsp;&nbsp;&nbsp;<b>$random_code</b></td>
    </tr>
    <tr valign=\"top\">
    <td colspan=\"2\" align=\"right\"><input name=\"randomness\" type=\"hidden\" id=\"randomness\" value=\"$random_code\">
    <input name=\"submit\" type=\"submit\" id=\"submit\" value=\"$lang_submit\" class=\"mailform_button\"></td>
    </tr>
    </table>
    </form>";
    }
    else
    {



    if ($checkdomain == "yes")
    {
    $sender_domain = substr($senders_email, (strpos($senders_email, '@')) +1);
    $recipient_domain = substr($sendto_email, (strpos($sendto_email, '@')) +1);
    if ($sender_domain == $recipient_domain)
    {
    print "Sorry, you cannot send messages from this domain ($sender_domain)";
    exit;
    }
    }


    $info_notice = $lang_sent;
    $mail_message = stripslashes($mail_message);
    $senders_email = preg_replace("/[^a-zA-Z0-9s.@-_]/", "-", $senders_email);
    $senders_name = preg_replace("/[^a-zA-Z0-9s]/", " ", $senders_name);
    $headers = "From: $senders_name <$senders_email> \r\n";
    $headers .= "X-Mailer: BELLonline.co.uk PHP mailer \r\n";
    mail($sendto_email, $mail_subject, $mail_message, $headers);
    print " <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
    <tr align=\"$title_align\" valign=\"top\">
    <td colspan=\"2\"><span style=\"$title_css\">$lang_title</span></td>
    </tr>
    <tr align=\"$title_align\" valign=\"top\">
    <td colspan=\"2\">$info_notice</td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_name</td>
    <td align=\"left\"><b>$senders_name</b></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_youremail</td>
    <td align=\"left\"><b>$senders_email</b></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_subject</td>
    <td align=\"left\"><b>$mail_subject</b></td>
    </tr>
    <tr valign=\"top\">
    <td width=\"100\" align=\"right\">$lang_message</td>
    <td align=\"left\"><b>$mail_message</b></td>
    </tr>
    </table>";
    }
    //print $link;
    ?>
     
    zuhairtaha, Jul 30, 2010 IP
  5. Amitoops

    Amitoops Well-Known Member

    Messages:
    1,388
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    148
    #5
    Eventhough you have to takethe help of google or just check carefully in inbox of gmail.
     
    Amitoops, Jul 30, 2010 IP
  6. Tavicu

    Tavicu Active Member

    Messages:
    120
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #6
    Thank you to everybody.

    I change my host and now is work perfect.
     
    Tavicu, Jul 31, 2010 IP