php mail() function not being sent to

Posted on 2009-04-29
Last Modified: 2012-05-06
I don't seem to be able to send an email to a particular domain using mail().  Works with any other email address.  I have queried this with the network administrator of the domain I'm sending it to, but he couldn't find any issues or where it's ending up.

Is there some other option in PHP I could use to get the message through?

Question by:astrotoggle

    Expert Comment

    It appears your PHP setup has no access to a local webserver. The best thing is to SMTP to another server. Either use SMTP GMail or your own ISP. PHP SMTP is much better anyway as it tends to get past spam filters because it originates from the correct place. Sending emails from function.mail often results is mail being blocked by spam filters.

    I'd use the Zend Framework class Zend_Mail.

    See url below for more info:
    include 'Zend/Mail.php';
    include 'Zend/Mail/Transport/Smtp.php';
    $config = array('ssl' => 'ssl',
    	'port' => 465,
    	'auth' => 'login',
    	'username' => '<your email>',
    	'password' => '<your password>');
    $transport = new Zend_Mail_Transport_Smtp('', $config);
    $mail = new Zend_Mail();
    $mail->addBcc($bcc, '<bcc name>');
    $mail->setFrom('<from email>', '<from name>');

    Open in new window

    LVL 17

    Accepted Solution

    I would investigate PHPMailer

    google phpmailer and check their examples and tutorials.

    Author Comment

    OK, I had trouble getting the Zend_Mail working.  Had more success with the PHPMailer, but I'm getting the following error:

    "Mailer Error: SMTP Error: Could not connect to SMTP host."
    $mailer = new PHPMailer();
    $mailer->Mailer = "smtp";
    $mailer->Host = 'ssl://';
    $mailer->Port = 465; 
    $mailer->SMTPAuth = TRUE;
    $mailer->Username = '';  
    $mailer->Password = 'mypassword';  
    $mailer->From = '';  
    $mailer->FromName = 'Me'; 
    $mailer->Body = 'This is the main body of the email';
    $mailer->Subject = 'This is the subject of the email';

    Open in new window

    LVL 17

    Expert Comment

    $mailer->Host = '';

    this is just supposed to be the host or IP, no protocol info.

    ssl:// is a protocol

    $mailer->Port = 465
    should be all you need to tell it to use a secure port.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now