Sender and reciever both get mail in php script [closed] - joomla

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want a php script in which sender and receiver both get email in core php....
Please give me web links of example or full script...

<?php
class MailerDaemon {
/**
* Set $isHTML to true in case the content to be send is in HTML
* if no CC is required, set $cc to be NULL
*/
public function sendMail($toEmail, $toName, $subject, $content, $isHTML, $cc) {
try {
$config = array(
'ssl' => 'tls',
'port' => '587',
'auth' => 'login',
'username' => '<Replace with your Mail Sender Username>',
'password' => '<Replace with your Mail Sender Password>',
);
$transport = new Zend_Mail_Transport_Smtp("<Replace with your SMTP Hostname>", $config);
Zend_Mail::setDefaultTransport($transport);
$mail = new Zend_Mail();
if ($isHTML) {
$mail->setBodyHtml($content);
} else {
$mail->setBodyText($content);
}
$mail->setFrom("<Replace with your Mail Sender Username/Email ID>", "<Replace with your Mail Sender Full Name>");
$mail->addTo($toEmail, $toName);
if($cc==NULL){$mail->addCc($cc);}
$mail->setSubject($subject);
$mail->send($transport);
} catch (Exception $exc) {
echo $exc->getTraceAsString();
return false;
}
return true;
}
}
?>
Download and Extract Zend Libraries
http://www.zend.com/en/community/downloads
Copy the "Zend" folder to your work directory which can be found in the extracted folder (hopefully under library directory) .
Paste the Following code in to a PHP File and Make Necessary Changes as indicated.

I'm a little confused as to exactly what you need, however seeing as you have tagged this question as Joomla related, I don't see the point in download Zend.
I think a simple contact form extensions will suffice.
http://extensions.joomla.org/extensions/contacts-and-feedback/contact-forms

Related

How to set a proxy using phpunit and selenium2?

I cant find example with PHPunit. I don't know what function i suppose to use. there are a lot examples for java but i cant find nothing for PHPUnit.
I opened the http://localhost:4444/wd/hub/static/resource/hub.html
and in capabilities there aren't settings for a proxy.
When i used the function setDesiredCapabilities the selenium always opened IE. Below are my "code"
class testtest extends PHPUnit_Extensions_Selenium2TestCase {
protected function setUp()
{
$capabilities=array('browser' => 'firefox');
$this->setDesiredCapabilities($capabilities);
$this->setBrowserUrl('http://www.test.com/');
}
public function testvvatg()
{
$this->url('http://www.test.com');
$url=$this->title();
$this->assertEquals('asdf', $url);
}
}
Please help thanks
While this topic is old, I found it while googling for a solution to the problem, so I figured I'd contribute.
Reading the source of PHPUnit Selenium2TestCase, you can see a link to the format that setDesiredCapabilities requires. In particular, you'd want the Proxy JSON Object format.
For example:
$this->setDesiredCapabilities(array(
"proxy" => array(
"proxyType" => "manual",
"httpProxy" => "proxyhost.com:1337",
"noProxy" => "dontproxy.me/please" //This one is undocumented. I'm not sure how to specify more than one
)
));

Laravel 4 Email not working

I've been looking for the answer for two days and still nothing. I've followed several tutorials where nothing more than just a few config settings are required, but my Laravel 4 app still doesn't want to send an e-mail. It always throws the same Exception and nobody seems to have the answer. It seems that I've tried everything but the working one.
Route::get('/sendemail', function() {
$data['user'] = 'Test User';
Mail::send('email.test', $data, function($m) {
$m->to('myemail#example.com')->subject('Email test');
});
});
But when I'm in the specified route, it always throws the same error:
Argument 1 passed to Swift_Transport_EsmtpTransport::__construct()
must implement interface Swift_Transport_IoBuffer, none given
The config is ok and even changing the driver from 'smtp' to 'mail' in config/mail.php throws also Exception.
Argument 1 passed to Swift_Transport_MailTransport::__construct() must be an instance of Swift_Transport_MailInvoker, none given
I'm stuck in here and I don't know that to do. My composer is up to date and PHP version is 5.4.4.
Any advice will be much appreciated.
Thank you.
You have probably found an answer by now.
But I think you need a second argument for the to.
Try:
$data = array('user' => $user);
Mail::send('email.test', $data, function($message) use ($user)
{
$message->to($user->email, $user->name)->subject('Email Test');
});

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.

remember me functionality in codeigniter

I have implemented remember me functionality as this question
How to create "remember me checkbox" using Codeigniter session library?
first answer.
I created a cookie with a random number code as value and it stored in db(user table). On login, db code checks with cookie value.It works fine on my localhost server. But in live server which has a subdomain url has problem.Also I tested it with another server with ip address as url. There also it is not working. In both cases cookie created but cant read the cookie. Please help me.
cookie set by
$auto_login_hash_code = uniqid();
$domain = $_SERVER['SERVER_NAME'];
$cookie = array(
'name' => 'rememberMe',
'value' => $auto_login_hash_code,
'expire' => 31536000,
'domain' => $domain,
'path' => '/'
);
$this->input->set_cookie($cookie);
and reading cookie by
if (get_cookie('rememberMe')) {
$hashcode = $this->CI->input->cookie('rememberMe');
$this->CI->load->model('loginmodel', '', true);
$username = $this->CI->loginmodel->get_username_by_hashcode($hashcode);//in this function setting session variables
}
Thanks in advance
iijb
you are getting library for that on github.
search remember me on github, load it and just follow below steps.
Verify cookie if token is present in database go to home page
$this->load->library('rememberme');
$cookie_user = $this->rememberme->verifyCookie();
if ($cookie_user)
{
$this->load->view('search_view');
}
else
{
// If checkbox is checked it return true either false
$checked = (isset($_POST['Checkbox1']))?true:false;
if($checked== true)
{
//$this->load->view('tested');
$this->load->library('rememberme');
$this->rememberme->setCookie($this->input->post('loginemil'));
//$this->rememberme->setCookie('set cookie here');
}
else{
dont set anything
}
}
Also this can be done by editing/extending system Session library.
First: In user login function add remember me check-
if($remember)
{
$data['new_expiration'] = 60*60*24*30;//30 days
$this->session->sess_expiration = $data['new_expiration'];
}
$this->session->set_userdata($data);
Second: Edit system Session library [I am not sure whether extending Session will work or not]
Go to this line in sess_read() method
if (($session['last_activity'] + $this->sess_expiration) < $this->now)
Before that line add following code
if(isset($session['new_expiration'])){
$this->sess_expiration = $session['new_expiration'];
}
This works fine for me.

Problems with cookies / MAMP / CodeIgniter

I'm having a problem with reading cookies on localhost, using MAMP and Codeigniter.
I'm trying to ude a cookie to authenticate acess to an admin area. I can set the cookie (I see it on my browser - Chrome) but i'm not able to read it after doing that to grant the acess. I've already tried lots of configurations, but none works. I really need some help on this.
Those are the essencial parts of my code:
Here I set the cookie
$cookie = array(
'name' => 'login',
'value' => 'true',
'expire' => '0',
'secure' => TRUE
);
set_cookie($cookie);
Here I redirect the user to login page if there is no cookie and to control panel if the cookie is set
function login_redirect() {
$this->load->helper('cookie');
if (uri_string() == 'admin/controlpanel') {
if ($this->input->cookie('login')) {
} else {
redirect('admin/');
}
}
if (uri_string() == 'admin') {
if ($this->input->cookie('login')) {
redirect('admin/controlpanel');
}
}
}
OBS: all this code is in the admin_model
Any tips?
Thanks and sorry about my english. I hope I've made myself clear.
Codeigniter has some problems with the Cookie and Session libraries when run on some localhost configurations. You'll spend hours trying to find out the particular problem with your setup. The best bet is to use generic PHP cookie/session when on localhost and use another library when in testing.
I appreciate that this is by no means the best solution but it's the best advice I can offer.

Resources