?
Solved

php mail() function not being sent to

Posted on 2009-04-29
4
Medium Priority
?
287 Views
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?

Cheers
0
Comment
Question by:astrotoggle
  • 2
4 Comments
 

Expert Comment

by:stmayes
ID: 24259280
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:
http://framework.zend.com/manual/en/zend.mail.html
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('smtp.gmail.com', $config);
 
$mail = new Zend_Mail();
$mail->addTo($email);
$mail->addBcc($bcc, '<bcc name>');
$mail->setFrom('<from email>', '<from name>');
$mail->setSubject($subject);
$mail->setBodyHtml($body);
$mail->send($transport);

Open in new window

0
 
LVL 17

Accepted Solution

by:
nplib earned 150 total points
ID: 24263821
I would investigate PHPMailer

google phpmailer and check their examples and tutorials.
0
 

Author Comment

by:astrotoggle
ID: 24266954
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."
require_once('class.phpmailer.php');
$mailer = new PHPMailer();
$mailer->Mailer = "smtp";
$mailer->Host = 'ssl://smtp.gmail.com';
$mailer->Port = 465; 
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'myusername@googlemail.com';  
$mailer->Password = 'mypassword';  
$mailer->From = 'myusername@googlemail.com';  
$mailer->FromName = 'Me'; 
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('someoneelse@googlemail.com');
$mailer->Send();

Open in new window

0
 
LVL 17

Expert Comment

by:nplib
ID: 24269957
$mailer->Host = 'smtp.gmail.com';

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.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

839 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