help with mailto body

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kaloreo
Forum Newbie
Posts: 4
Joined: Fri Apr 23, 2010 12:58 pm

help with mailto body

Post 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!!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: help with mailto body

Post by requinix »

Code: Select all

string = "mailto:" + email
if email is "email2@email2.com" then string = string + "?subject=...&body=..."
kaloreo
Forum Newbie
Posts: 4
Joined: Fri Apr 23, 2010 12:58 pm

Re: help with mailto body

Post 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!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: help with mailto body

Post 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
kaloreo
Forum Newbie
Posts: 4
Joined: Fri Apr 23, 2010 12:58 pm

Re: help with mailto body

Post 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!
kaloreo
Forum Newbie
Posts: 4
Joined: Fri Apr 23, 2010 12:58 pm

Re: help with mailto body

Post by kaloreo »

I think I've got it!! Thanks for pointing me in the right direction!
Post Reply