1

I need help about PHP's mail function on ipage hosting this script worked good on other hosts, but when I used it on ipage the site doesn't send any mail at all. I searched on the web and found something like this.

Mail from ipage utilizing PHP. You have to established the “From: ” discipline while in the mail function as ‘From: /usr/sbin/sendmail’.”\r\n”. So in the scenario the variable $from will be $from = ‘From: /usr/sbin/sendmail’.”\r\n”

So if anyone can help me how to implement this on this code:

$installUrl = $set['installUrl'];
            $siteName = $set['siteName'];
            $siteEmail = $set['siteEmail'];

            $subject = $subscribeEmailSubject;
            $message = '<html><body>';
            $message .= '<h3>'.$subject.'</h3>';
            $message .= '<p>'.$subscribeEmail1.'<br>'.$installUrl.'subscribe.php?email='.$subscribeEmail.'&hash='.$hash.'</p>';
            $message .= '<hr>';
            $message .= '<p>'.$subscribeEmail2.' '.$siteName.'.</p>';
            $message .= '<p>'.$subscribeEmail3.'<br>'.$siteName.'</p>';
            $message .= '</body></html>';
            $headers = "From: ".$siteName." <".$siteEmail.">\r\n";
            $headers .= "Reply-To: ".$siteEmail."\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

            if (mail($subscribeEmail, $subject, $message,  $headers)) {
                $msgBox = alertBox($subscribeConfMsg, "<i class='fa fa-check-square'></i>", "success");
                // Clear the Form of values
                $_POST['subscribeEmail'] = '';
            }

Thank you.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alen Kofrc
  • 11
  • 2
  • `From` must be a valid email address. because you are using sendmail you can pass additional parameters to sendmail using the 5th parameter, like `mail($subscribeEmail, $subject, $message, $headers, '-fwebmaster@yoursite.com')`. Please check the error logs, you can find details on failure there. – bansi Dec 20 '14 at 13:13
  • when i contacted theipage support the told me to set /usr/sbin/sendmail as a path to sendmail in the mail() function do you know how to do that? – Alen Kofrc Dec 20 '14 at 13:24
  • `mail()` can be rather unreliable, depending on what anti-spam measures a host has put in place, and how their MTA is otherwise configured. I wouldn't use it myself - install a good quality mailer library instead, such as PHPMailer or SwiftMailer. – halfer Dec 20 '14 at 14:31

0 Answers0