Page 1 of 1

help with mailto body

Posted: Fri Apr 23, 2010 1:04 pm
by kaloreo
Hello!

I'm maintaining a drupal site and new to PHP. On the site's contact us page there are a couple of email links. If a user clicks the mailto for 'email2'@email2.com' I want to include some specific text in the body of the email. Here is my code so far:

function theme_emailbox($row) {
if($row->email) {
$lnk = 'mailto:'.$row->email;
$lnk .='?SUBJECT=here_is_the_subject_for_all';
$lnk .='&BODY=here_is_the_body_BUT_only_when_mailto_is_email2';
if($row->cc) $lnk .= '&CC='.$row->cc;
return l(t($row->section),$lnk,null,null,null,false,true);
}
}

Of course the subject and body get filled in the same regardless of which mailto link was clicked. How can I set a condition that if the mailto is email2, include the body text, otherwise do not?

Thanks so much for any help!!

Re: help with mailto body

Posted: Fri Apr 23, 2010 1:54 pm
by requinix

Code: Select all

string = "mailto:" + email
if email is "email2@email2.com" then string = string + "?subject=...&body=..."

Re: help with mailto body

Posted: Fri Apr 23, 2010 2:01 pm
by kaloreo
Thanks but this didn't work for me. I don't know if my code is different because it's in a drupal module, but for instance, I can't use " I have to use '. Still it didn't work though. If I didn't mention - I am very new to this so if you could show me exactly where your code would go (inside my code) that would help. I am only guessing and doing trial and error otherwise. Thank you!

Re: help with mailto body

Posted: Fri Apr 23, 2010 2:51 pm
by requinix
What I posted doesn't look like PHP code, right?

Code: Select all

function theme_emailbox($row) {
	if($row->email) {
		$lnk = 'mailto:'.$row->email;
		// if the email is "email2@email2.com" then
			$lnk .='?SUBJECT=here_is_the_subject_for_all';
			$lnk .='&BODY=here_is_the_body_BUT_only_when_mailto_is_email2';
			if($row->cc) $lnk .= '&CC='.$row->cc;
		//
		return l(t($row->section),$lnk,null,null,null,false,true);
	}
}
if

Re: help with mailto body

Posted: Fri Apr 23, 2010 3:58 pm
by kaloreo
I'm still confused... Yes, what you posted does not look like PHP code. And in your reply, the only thing you added to my code you also remarked out? (At least I think that's what // does.) Give me another clue please!

Re: help with mailto body

Posted: Fri Apr 23, 2010 4:54 pm
by kaloreo
I think I've got it!! Thanks for pointing me in the right direction!