Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Mail Quckie

  • 17-04-2008 11:14am
    #1
    Registered Users, Registered Users 2 Posts: 3,470 ✭✭✭


    Lads, have php5 running on a windows nt server.

    the asp mail is working fine:
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    objCDOMail.From    = "blah blah"
    objCDOMail.To      = strTo
    objCDOMail.Cc	   = strCc
    objCDOMail.Subject = strSubject
    objCDOMail.Body    = strBody
    objCDOMail.Send
    Set objCDOMail = Nothing
    

    but the php version is crashing the page
    function send_email($to,$msgsubject, $msg){
    	@$CDONTS = new COM("CDONTS.NewMail");
    	@$CDONTS->From = "blah blah"; 
    	@$CDONTS->To = $to; 
    	@$CDONTS->Subject = $msgsubject;
    	@$CDONTS->BodyFormat = 1; 
    	@$CDONTS->MailFormat = 1; 
    	//@$CDONTS->AttachFile("c:\tmp\somefile.txt");
    	@$CDONTS->Body = $msg;
    	@$CDONTS->Send();
    	@$CDONTS->Close();
    	}
    

    can anyone see anything wrong with it?

    I'd prefer to use the simple mail command but won't work on stupid work server!


Comments

  • Registered Users, Registered Users 2 Posts: 6,602 ✭✭✭daymobrew


    I am using the free sendmail for Windows (site down for me atm). It comes with XAMPP for Windows.

    I point it at my hosting SMTP server and include the username/password for the 'from' account.
    I use the PEAR Mail_Mime module to send my emails.
    [PHP]
    include('Mail.php');
    include('Mail/mime.php');

    $to = 'recipient@another-domain.com';
    $textfile = '/path/to/email/body.txt';
    $file = '/path/to/attachment.doc';
    $crlf = "\n";
    $hdrs = array( 'From' => 'from_addr@domain.com', 'Subject' => 'The email subject' );
    $mime = new Mail_mime($crlf);
    // You can sent a string and FALSE instead of a file.
    $mime->setTXTBody($textfile, TRUE);
    // Obviously attaching a file is optional.
    $mime->addAttachment($file);

    //do not ever try to call these lines in reverse order
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail =& Mail::factory('mail');
    $sendresult = $mail->send($to, $hdrs, $body);
    if (PEAR::isError($sendresult))
    print($sendresult->getMessage());
    [/PHP]


Advertisement