Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Mail Sending

  1. #1
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Mail Sending

    Hi, i was wondering as i have a importer script how i would make the emails sent to the imported contacts send from the person who imported the emails:

    Eg:

    someone@hotmail.com imports there contact list

    It then sends email to all of their contacts but from someone@hotmail.com

    thanks

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's your current mail script look like? Or do you not have one yet?
    Matt Tyree
    TyreeOnline
    If I didn't just "make it worse," show me some love! Hit me with the rep points! :) (The white scales icon on the left)

  • #3
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Well it's the hotmail importer which can be found at www.aur-phala.com/hotmail/

  • #4
    Banned
    Join Date
    Dec 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    think he meens show the code

  • #5
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Here's the index.php

    PHP Code:
    <?php 
    chdir
    ('/home/jaynbhav/public_html/forum'); 
    require_once(
    '/home/jaynbhav/public_html/forum/global.php'); 
    ?> 

    <?

    if(intval(@$_POST['update'])==1){

    $email=stripslashes(@$_POST['EmailAddress']);

    $password=stripslashes(@$_POST['Passwd']);

    $output=null;



    include(
    "hotmailimporter.php");



    $getdata=getdata($email,$password);



    if(!
    $getdata){$output="<b>Failed to import addresses. Please check your username &amp; password.</b>";}else{

    $getinfo=getinfo($getdata,1);

    $getname=getinfo($getdata,0);

    $rt=0$xgct=0;

    while(
    $rt!=count($getinfo)){

    if(
    $getinfo[$rt+1]!=null){

            
    $xgct++;

            
    $output.="<tr><td><input type=\"checkbox\" id=\"email[]\" name=\"email[]\" value=\"".htmlspecialchars($getinfo[$rt+1],ENT_QUOTES)."\" checked></td>

            <td width=\"200\">"
    .htmlspecialchars($getname[$rt+1],ENT_QUOTES)."</td><td width=\"200\" bgcolor=\"#eeeeee\">".htmlspecialchars($getinfo[$rt+1],ENT_QUOTES)."</td></tr>";

    }



    $rt++;

    }



    $checkrow="<tr><td colspan=\"3\" bgcolor=\"#cccccc\"><a onclick=\"select_all(1);\" href=\"javascript: void(0);\"><font color=\"#666666\"><b>Select All</b></font></a> | <a onclick=\"select_all(0);\" href=\"javascript: void(0);\"><font color=\"#666666\"><b>Unselect All</b></font></a></td></tr>";



    $output="

    <form name=\"formlist\" method=\"POST\" action=\"sendmail.php\">

    <table border=\"1\" bordercolor=\"#cccccc\" class=stxt cellspacing=\"6\" cellpadding=\"6\" align=\"center\" style=\"border-collapse: collapse\" width=\"450\">"
    .$checkrow.$output.$checkrow."</table>

    <br/><span class=\"stxt\">There are a total of <b>"
    .$xgct."</b> emails being imported.</span><br/><br/><input type=\"submit\" class=\"stxt\" value=\"Send Invitation\"></form>

    "
    ;



    }

    }



    ?>

    Here's the sendmail.php:

    PHP Code:
    <html>

    <head>

    <title>Send Mail Test</title>

    <style><!--

    BODY {font: normal 11px Arial, Verdana, Tahoma;}

    .pd {margin-top: 15px; padding: 5px; background-color: #f4f4f4;}

    --></style>

    </head>

    <?





    function sendmail($from="service@livingitlarge.com",$to,$subject,$message){

    //set sender's email here

    //$from="$sender_name";

    $headers 'From: '.$from.'' "\r\n" ;

    //$headers = 'From: '.$from.'' . "\r\n" .

    //              'Reply-To: '.$from.'' . "\r\n" .

    //           'X-Mailer: PHP/' . phpversion() . "\r\n" .

    //           'Return-Path: '.$from.'' ;

    $headers .= "Content-Type: text/html\n";
    $headers .= '$email'.$eol;
    $headers .= 'Reply-To: $email <$wmail>'.$eol;
    $headers .= 'Return-Path: $email <$email>'.$eol;    // these two to set reply address
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
    $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
    # Boundry for marking the split & Multitype Headers
    $mime_boundary=md5(time());
    $headers .= 'MIME-Version: 1.0'.$eol;
    $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
    $msg ""
    if (
    mail($to$subject$message$headers)){return true;}else{return false;}

    }



    //== Set subject and message

    $subject_header="Newsletter"//put your subject in PHP Alphanumeric Format e.g. "Hello. This is a test..."



    $msgfile="mailmessage.php"//enter the filename which points to your mail content file in html format e.g. "mailmessage.html"



    //========================== do not edit beyond this line

    ob_start(); require($msgfile); $message=ob_get_contents(); ob_end_clean();

    //== End retrieval



    $email = @$_POST['email'];

    if(!
    $email){$email = array();}





    foreach (
    $email as $emailaddress) {

    /*

    $i=1;

    if($i>=3)exit;

    else

    {

        switch ($i) {

        case 0:

            $from="invitations@wallop.com";

            $subject="Welcome to wallop.com from your friends";

            $message = str_replace( '$sender_name', $from,$message);

            break;

        case 1:

            $from="invitations@google.com";

            $subject="Welcome to Google.com from your friends";

            $message = str_replace( '$sender_name', $from,$message);

            break;

        case 2:

            $from="invitations@dlnow.com";

            $subject="An invitation to DLnow.com from your friends";

            $message =  str_replace( '$sender_name', $from,$message);

            break;

        }

    */

      
    $from="service@livingitlarge.com";

      
    $subject=$subject_header." ".$from;

        
    $message =  str_replace'$sender_name'$from,$message);

        

        if(@
    sendmail($from,$emailaddress,$subject,$message)){

          echo 
    htmlspecialchars($emailaddress,ENT_QUOTES)."&ndash; <b>Mail Sent Successfully</b><br/>";

        }else{

          echo 
    htmlspecialchars($emailaddress,ENT_QUOTES)."&ndash; <b>Send Mail Failed</b><br/>";

        }

        
    sleep(2);

    //$i++;

    //}

    }



    print 
    "<div class=\"pd\"><b>Total of ".count($email)." selected email addresses retrieved</b></div>";

    ?>

  • #6
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First, on your index.php, you're going to need to collect the user's email address and send it to sendmail.php. For this example I'll set it to $userEmail.

    Next, change your sendmail() function (I've omitted all the commented line):
    PHP Code:
    function sendmail($from,$to,$subject,$message){ 
      
    $headers 'From: '.$from.'' "\r\n" 
    $headers .='Reply-To: '.$from.'' "\r\n" 
    $headers .='X-Mailer: PHP/' phpversion() . "\r\n" 
    $headers .='Return-Path: '.$from.'' "\r\n" 
    $headers .= "Content-Type: text/html\n" ;
    # Boundry for marking the split & Multitype Headers 
    $mime_boundary=md5(time()); 
    if (
    mail($to$subject$message$headers)){return true;}else{return false;} 

    In sendmail.php...define $from outside of the foreach statment:
    PHP Code:
    $from $_POST['userEmail']; 
    Next, change your foreach statement toward the end of the sendmail.php file:
    PHP Code:
    foreach ($email as $emailaddress) { 

      
    $subject=$subject_header." ".$from

        
    $message =  str_replace'$sender_name'$from,$message); 

        if(@
    sendmail($from,$emailaddress,$subject,$message)){ 

          echo 
    htmlspecialchars($emailaddress,ENT_QUOTES)."&ndash; <b>Mail Sent Successfully</b><br/>"

        }else{ 

          echo 
    htmlspecialchars($emailaddress,ENT_QUOTES)."&ndash; <b>Send Mail Failed</b><br/>"

        } 

        
    sleep(2); 


    I don't really understand what you're doing with the $message definition there. Where is the text of your message?

    So, while I haven't tested this. It should get the $email array, the user's email address and then send an email to each address in the $email array FROM the user's email address.

    Hope that helps!
    Matt Tyree
    TyreeOnline
    If I didn't just "make it worse," show me some love! Hit me with the rep points! :) (The white scales icon on the left)

  • #7
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts
    im still baffled :S

  • #8
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts
    bump...

  • #9
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The text of the message is stored in a file- mailmessage.php in our case ...
    Also this script is not working now with hotmail , I have it for yahoo and gmail if you need it please contact me to send it.My email address is


    $msgfile="mailmessage.php"; //enter the filename which points to your mail content file in html format e.g. "mailmessage.html"
    Last edited by nikolas22t; 07-11-2007 at 03:12 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •