Question

I have been trying to find a fix for this issue. The creators of the script are not very helpful. They told me to have receivers check the spam folder. I am mailing this to several test email addys on my own and HAVE checked SPAM/Junk.

I need the email confirmation to be sent to the customer. The problem is: the email only sends to GMail and AOL. Yahoo, hotmail, etc are not receiving the emails. The emails did not go into spam.

After contacting the host, they said my shared IP is likely blacklisted and I should use an external mail server or SMTP.

I know very little about PHP but am learning. I really appreciate the help.

//----Script tested to see if the server will work with GMail:

require_once "Mail.php";

$from = '<mymail.gmail.com>';
$to = '<somemail.yahoo.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";

$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);

$smtp = Mail::factory('smtp', array(
    'host' => 'ssl://smtp.gmail.com',
    'port' => '465',
    'auth' => true,
    'username' => 'mygmail@gmail.com',
    'password' => 'myPASS'
));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
    echo('<p>' . $mail->getMessage() . '</p>');
} else {
    echo('<p>Message successfully sent!</p>');
}

//----ERROR: authentication failure [SMTP: Invalid response code received from server (code: 534, response: 5.7.14 Please log in via your web browser and then try again. //----Also Tried $host = 'smtp.gmail.com'; AND different ports

//----Script in the functions php file in Script

function sendMail($email, $subject, $template,$serviceID, $data=null) {
    global $baseDir;
    $serviceSettings = getService($serviceID);
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=utf-8\n";
    $headers .= "From: 'MyName' <mymail@mydomain.net> \n";

 if ($data == null) {
    $message = $template;
 } else {
    $data ['{%server%}'] = $_SERVER['SERVER_NAME'];
    foreach ($data as $k => $v) {
        $$k = $v;
    }
    ob_start();
    include MAIN_PATH . "/emailTemplates/{$template}";
    $templ = ob_get_contents();
    ob_clean();     //$templ=file_get_contents($_SERVER["DOCUMENT_ROOT"].$baseDir."emailTemplates/{$template}");
    $message = strtr($templ, $data);
}

//$message.="<br><br><a href='http://{$_SERVER['SERVER_NAME']}'><img src='http://{$_SERVER['SERVER_NAME']}/images/logo_sm.png'></a>";

mail($email, $subject, $message, $headers);
}

function sendMailFile($email, $subject, $template,$serviceID, $data=null,$file=null) {
global $baseDir;

$boundary = "--" . md5(uniqid(time()));
$EOL = PHP_EOL;

$serviceSettings = getService($serviceID);
$headers = "MIME-Version: 1.0;$EOL";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"$EOL";
$headers .= "From: 'MyName' <mymail@mydomain.net> $EOL";
$multipart = "--$boundary$EOL";
$multipart .= "Content-Type: text/html; charset=utf-8$EOL";
$multipart .= "Content-Transfer-Encoding: Quot-Printed$EOL";
$multipart .= $EOL;

if ($data == null) {
    $message = $template;
} else {
    $data ['{%server%}'] = $_SERVER['SERVER_NAME'];
    foreach ($data as $k => $v) {
        $$k = $v;
    }
    ob_start();
    include MAIN_PATH . "/emailTemplates/{$template}";
    $templ = ob_get_contents();
    ob_clean();

    //$templ=file_get_contents($_SERVER["DOCUMENT_ROOT"].$baseDir."emailTemplates/{$template}");
    $message = strtr($templ, $data);
}

$multipart .=$message;
$name = "addToCalendar.ics";
$multipart .= "$EOL--$boundary$EOL";
$multipart .= "Content-Type: application/octet-stream; name=\"$name\"$EOL";
$multipart .= "Content-Transfer-Encoding: base64$EOL";
$multipart .= "Content-Disposition: attachment; filename=\"$name\"$EOL";
$multipart .= $EOL; // Ãâ€-EDITED-Out-Encrypted-Code-On-Purpose-»Ã° 
$multipart .= chunk_split(base64_encode($file));

$multipart .= "$EOL--$boundary--$EOL";


mail($email, $subject, $multipart, $headers);
}

Does anyone think I can get some kind of mail system to work with this script learning my limitations with the host?

Thank you!

Was it helpful?

Solution

Can you explain is that error 534 occurring all the time, or just when attempting email addresses other than @gmail. etc?

If it was all the time, I would ask if you had a firewall on your server, and is it blocking outgoing port 465?

If it is only creating an error when sending to other email addresses, then it is not an issue with the smtp host, but when Google is relaying the email to other mail servers round the world.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top