CakePHP email not sending but showing in debug mode - debugging

My CakePHP should send an email when a button is clicked, however it doesn't. Also, the email will be displayed as a flash message if I run it in debug mode: ($this->Email->delivery = 'debug';).
Note: Email is set up to set up to use PHP mail() function.
Code to call the email function:
$this->_sendUpdateEmail( $this->Auth->user('id'), $about_id );
Email function
function _sendUpdateEmail($from_user_id, $about_id) {
$fromUser = $this->User->read(null, $from_user_id);
$users = $this->User->find('all', array(
'conditions' => array('User.distribution =' => 1)
));
# loop to send email to all users who are marked as on the distribution list
for($i = 0, $size = sizeof($users); $i < $size; ++$i) {
$user = $users[$i]['User'];
$this->Email->from = $fromUser['User']['email'];
$this->Email->replyTo = $fromUser['User']['email'];
$this->Email->to = $user['email'];
$this->Email->subject = 'Test email';
$this->Email->template = 'update';
$this->Email->sendAs = 'both'; // both = html and text
$this->set('user', $user);
$this->set('about', $about_id);
$this->Email->send();
$this->Email->reset();
}
}
Any ideas as to why the emails show in debug mode but won't actually send?

I think the reason why my emails were not sending was because there was no mail server configured on the web server my CakePHP was running on so there was no way to route the emails. However, this meant they would show up in the debug because they were generated successfully, just not sent.
In the end, I ended up using my company's Exchange mail server using the SMTP settings.
Code to use SMTP to send CakePHP emails
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => '192.168.0.244',
);
// Other email code here, e.g. from and to etc...
$this->Email->delivery = 'smtp';

I think the issue here is that mail server is not set right Linux comes built in with mail sending functionality but not windows (no idea on mac). look into smtp options as u can easily setup smtp email sender on Windows
Setting up smtp windows - http://publib.boulder.ibm.com/infocenter/cqhelp/v7r1m2/index.jsp?topic=/com.ibm.rational.clearquest.webadmin.doc/topics/c_config_email_smtp_win.htm
and
http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP

Related

Orange SMS Gateway APi 1.1 is not working with php

I purchased a number of messages , and followed all the steps
including
1. access token
2. client id and secret id
but the sms never reach the mobile number
iam using this code based on the api documentation
<?php
require 'Path to Osms ';
use \Osms\Osms;
$config = array(
'token' => 'my token'
);
$osms = new Osms($config);
$senderAddress = "tel:+200000";
$receiverAddress = "tel:+20 my number";
$message = "Hello World!";
$senderName = "Optimus Prime";
$osms->sendSms($senderAddress, $receiverAddress, $message,
$senderName);
what happens is that the number of messages at the website keeps decreasing , but the sms never arrives the mobile
Use this library instead of what you've used !
More explications are here

Mailchimp api not sending goodbye email -with https://github.com/drewm/mailchimp-api

when unsubscribing an user I want de default Mailchimp goodbye email to be send.
I'm using the following code
$mailchimp = new MailChimp($apiKey);
$md5 = md5($_POST['email']);
$result = $mailchimp->put("lists/$listId/members/$md5", [
'status' => 'unsubscribed',
'send_goodbye' => true
]);
I have the "Send unsubscribe confirmations to subscribers" check in the relevant list.
It unsubscribes the user but never sends the email.
Any idea why?
I'm using the following php wrapper:
https://github.com/drewm/mailchimp-api
Thanks

Magento send email in custom module

I Need to create an email template. Also I need to load that customer template into another .phtml file and edit before send the email. After editing only I need to send the email. Can anyone please help me how to do this?
I searched and tried for this, but I only found articles related to send email without editing the existing email template.
example: http://www.caritorsolutions.com/blog/158-send-email-from-custom-module-in-magento
You can create an email template when going to System > Transactional Emails. The name you put in is the unique identifier for that template.
<?php
$templateName = 'template_name_you_put_in_in_the_backend';
$to = 'johndoe#example.com';
$customerName = 'John Doe';
// Load our template by template_id
$emailTemplate = Mage::getModel('core/email_template')->loadDefault($templateId);
$vars = array(
'customer_name' => $customerName
// Other vars that can be used in the mplate
);
// Store sends it
$senderName = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME);
$senderEmail = Mage::getStoreConfig('trans_email/ident_general/email');
$emailTemplate->setSenderName($senderName);
$emailTemplate->setSenderEmail($senderEmail);
//Send the email!
$emailTemplate->send($to, $customerName, $emailTemplateVariables);
You can of course edit this file through System > Transactional Emails. If this isn't what you mean, can you clarify what you mean by 'editing the existing email template' ?

how to make working SMTP_validateEmail on live site using php

Not working SMTP_validateEmail on live site using php
https://code.google.com/p/php-smtp-email-validation/
<?php
/**
* Example 1
* Validate a single Email via SMTP
*/
// include SMTP Email Validation Class
require_once('smtp_validateEmail.class.php');
// the email to validate
$email = $_POST['name'];
// an optional sender
$sender = $_POST['name'];
// instantiate the class
$SMTP_Validator = new SMTP_validateEmail();
// turn on debugging if you want to view the SMTP transaction
//$SMTP_Validator->debug = true;
// do the validation
$results = $SMTP_Validator->validate(array($email), $sender);
// send email?
if ($results[$email]) {
echo 1;
} else {
echo 0;
}
enter code here
?>
i am having problem on live site but it works fine in localhost.it shows the print_r($results) in the localhost but shows array(0) result in live.i also find $this->sock value in the class smtp_validateEmail.class function validate(email) value empty in live. how to solve this issue any help will be very thankful.
That "Add your web server ip address to var $nameservers = array(‘192.168.0.1’); and if your web server has Port number then update it here var $port = (Port number); Hope you will get the output by making this changes." Only work if you are sending mail with that script but cant tell if that mail checked is good one or not... I have been testing the code, try all changes, but still cant check other mails outside my domain. I can only make it work on my local and webserver host. Still cant call other servers to check if other mails from outside my domain are valid. Working on it.
Complete downloads are here for others to test : https://code.google.com/p/php-smtp-email-validation/downloads/list
Add your web server ip address to var $nameservers = array(‘192.168.0.1’);
and if your web server has Port number then update it here var $port = (Port number);
Hope you will get the output by making this changes.

Send SMS from Web (are there some providers for this)?

I'd like to have something like what the app.net site has. You click a button and get the option to send a link to your phone via SMS (or email). What are some options for implementing the sms side of things, and are there services or open source packages that provide this?
Here's a random example from app.net . Click the "Get this App" button to see what I mean.
Something like this would even work for me Send link to Phone Where "saasSMS.com" is some service that handles the whole sms side of things. Ideally could either handle that via a link or via a form post (and it would redirect back to your site on success or something).
What I don't want: A drop down that makes you pick your carrier and some php page that tries to email you #vtext.com or similar. That is just not slick enough.
You can use the ViaNett HTTP API to send SMS messages worldwide without specifying the operator.
As long as your backend supports invoking HTTP requests it will work.
Here is an example written in PHP:
<?php
// Register here to get a username and password:
// http://www.vianett.com/en/free-demonstration-account
if (vianett_sendsms('username', 'password', 'example', '+4412345678', 'Hello world', $error)) {
echo 'Success!';
} else {
echo $error;
}
function vianett_sendsms($username, $password, $from, $to, $msg, &$response=null) {
$url = 'https://smsc.vianett.no/v3/send.ashx';
$data = array(
'user' => $username,
'pass' => $password,
'src' => $from,
'dst' => $to,
'msg' => $msg
);
$qs = http_build_query($data);
$response = file_get_contents($url.'?'.$qs);
return $response == '200|OK';
}
We're getting good results from http://www.twilio.com
For direct SMS, you can try contacting a service provider and make a contract with it. If its for small projects and the server is accessible, you could put a GPRS mobile phone or modem and send with it.

Resources