简体   繁体   中英

Mailx passthru() with included variable

Having some troubles getting this to work, so I thought I'd ask you folks. I'm just trying to have a user simply enter their email in an input field, then shoot them an email with a confirmation number. The email sends, but cannot get the confirmation number to show within the email.

     $cmd = 'echo "Please copy and paste the following link into your browser to confirm your registration: domain.subdomain.ca/user/confirm/"'.$confirmation_code.' | mail -s "Please confirm your login registration" foo@bar.com';
     $result = 0;

     passthru($cmd, $result);

Now I've tried it that way with concatenation, but I've also tried inline since it's just echoing a simple statement, so I tried to use $confirmation_code within the double quotes, still nothing. ALso tried ${confirmation_code} and {$confirmation_code} as people suggested in the passthru docs.

The email sends, everything works, but I cannot get the confirmation code to show in the email, so if anyone has a solution it'd be greatly appreciated!!

You are having problem with quotes in command string. Change it to: $cmd = 'echo "Please copy and paste the following link into your browser to confirm your registration: domain.subdomain.ca/user/confirm/'.$confirmation_code.'" | mail -s "Please confirm your login registration" foo@bar.com'; $cmd = 'echo "Please copy and paste the following link into your browser to confirm your registration: domain.subdomain.ca/user/confirm/'.$confirmation_code.'" | mail -s "Please confirm your login registration" foo@bar.com'; and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM